/* calcpay2.cpp 6/5/08 David Klick Demonstration of if/else 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; if (hours > 40.0) { gross = 40.0 * rate + (hours - 40.0) * 1.5 * rate; } else { gross = hours * 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(); }