/* calcpay1.cpp 6/5/08 David Klick Demonstration of "if" and formatted output from class. */ #include #include using std::cin; using std::cout; using std::fixed; using std::showpoint; using std::setprecision; void cont(); int main() { double hours = 0.0; double rate = 0.0; double gross = 0.0; cout << "Enter the employee's hourly rate: "; cin >> rate; cout << "Enter the hours the employee worked: "; cin >> hours; gross = hours * rate; if (hours > 40.0) { gross += (hours - 40.0) * .5 * rate; } cout << "The gross pay is $" << fixed << showpoint << setprecision(2) << gross << "\n\n"; cont(); return 0; } void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); }