/* ----------------------------------------
Compute pay based on the following rules
(1) Between 0-40 hours: $8.00 per hour
(2) Hours over 40 : $12.00 per hour
---------------------------------------- */
# include
# include
using namespace std;
int main( )
{
const double HOURLY_RATE = 8.0;
const double OVERTIME = 12.0;
double hours;
double pay;
// Input hours
cout << "This program computes weekly pay based on the number of hours worked." << endl;
cout << "Enter the number of hours worked." << endl;
cin >> hours;
// Calculate pay
if (hours <= 40)
pay = hours*HOURLY_RATE;
else
pay = 320.0 + (hours - 40.0)*OVERTIME;
// Output pay
// Note the use of the format manipulators
cout << setiosflags(ios::fixed)
<< setiosflags(ios::showpoint)
<< setprecision(2);
cout << "The weekly pay is = $" << pay << endl;
return 0;
}
               (
geocities.com/vuumanj)