The problem states that:
Design a PayRoll class that has data members for an employee’s hourly pay rate and number of hours worked. Write a program with an array of seven PayRoll objects. The program should read the number of hours each employee worked and their hourly pay rate from a file and call class functions to store this information in the appropriate objects. It should then call a class function, once for each object, to return the employee’s gross pay, so this information can be displayed.
My professor has also included that the user should be able to input the data (not from a data file) and that the user can choose to stop entering payroll objects before they reach 7.
What I cannot figure out is how to allow the user to stop entering payroll objects.
This can be done with your current for loop like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
//declare a char input
for (x = 0; x < NUM_EMPLOYEES; x++)
{
cout << "Enter Employee # " << (x) << " rate of pay per hour: ";
cin >> pay;
cout << "Enter Employee # " << (x) << " hours worked for the week: ";
cin >> hours;
employee[x].setPayRate(pay);
employee[x].setHours(hours);
//cout a statement like "Continue(y/n)?"
//cin input
//check if input is n, then break else do nothing
}