/* DemoFormattedIO1.cpp CIS 150 5/26/2005 David Klick This program demonstrates formatted output. */ #include #include using std::cout; using std::endl; using std::cin; using std::setw; using std::setprecision; using std::fixed; using std::showpoint; int main(void) { double hours, rate; double grossPay; cout << "Enter hours: "; cin >> hours; cout << "Enter rate: "; cin >> rate; grossPay = hours * rate; cout << "Unformatted gross pay: " << grossPay << endl; cout << "Formatted gross pay: " << fixed << showpoint << setw(7) << setprecision(2) << grossPay << endl; return 0; } /* Sample output from two runs of program: Enter hours: 20.0 Enter rate: 15.75 Unformatted gross pay: 315 Formatted gross pay: 315.00 Enter hours: 10.25 Enter rate: 5.75 Unformatted gross pay: 58.9375 Formatted gross pay: 58.94 */