// A program to calculate and output the salaries for 10 employees based on rate of pay and
// hours worked data entered by a user
// File: ch3prg1a.cpp
#include <iostream.h>
const int REGULAR_HOURS = 40;
const double OVERTIME_ADJUSTMENT = 1.5;
void main()
// Purpose: to calculate the salaries for 10 employees
// Receives: NONE
// Returns: NONE
{
double rateOfPay;
double overtimeRateOfPay;
double regularSalary;
double overtimeSalary;
double fullSalary;
double hoursWorked; // can be a fraction of an hour
int count = 0; // initialize the counter to 0
cout << "This program will allow you to calculate the salary of 10 employees\n";
cout << " who will be paid by the hour.\n\n";
while (count < 10)
{ cout << "Please enter your rate of pay ";
cin >> rateOfPay;
cout << "Please enter the hours you worked this week ";
cin >> hoursWorked;
if (hoursWorked > REGULAR_HOURS)
{ regularSalary = REGULAR_HOURS * rateOfPay;
overtimeRateOfPay = rateOfPay * OVERTIME_ADJUSTMENT;
overtimeSalary = (hoursWorked - REGULAR_HOURS) *
overtimeRateOfPay;
fullSalary = regularSalary + overtimeSalary;
}
else
{ fullSalary = hoursWorked * rateOfPay;
}
cout << "Your salary is: " << fullSalary << endl;
count++;
}
cout << "All salaries have been processed....Good Bye\n";
}