// Mr. Minich
// CMPSC 201
// Ch. 3 Demo Program #6
// January 30, 2000
// Purpose - to illustrate the use of setprecision, setf, and setw
#include <iostream>
#include <iomanip>
using namespace std;
// necessary for setprecision & setw
int main()
{
double exact = 0.0; // the price of a car
cout << "Enter the price of the car: ";
cin >> exact;
cout << "Roughly, the car will cost $" << setprecision(2) << exact << "." << endl;
// setprecision forces C++ to round or truncate future values to a certain number
// of overall significant digits sometimes causing values to be printed in scientific notation
// However, using setiosflags(ios::fixed) manipulator as well as setprecision causes all
// future cout's to print normal rather than in scientific notation.
// Also, it causes the setprecision to apply to the number of digits
// to the right of the decimal place rather than the number of digits
// in the whole value.
cout << "The price $" << setiosflags(ios::fixed) << setprecision(2) << exact << " probably looks better." << endl;
cout << "More space is provided for the price here: $" << setw(10) << exact << endl;
// setw allocates more space for a value to be printed and can be used to make columns appear nicely formatted.
return 0;
}// end of main