I am trying to figure out how to allow my program to have another name input indefinitely. Right now, if you'd want to look up another name, you'd need to restart the entire program. This program calculates employee net pay value. All employees have a standard $45 deduction from their checks. If an employee does not earn enough to cover the deduction, an error is displayed.
#include <iostream>
#include <string>
using namespace std;
int
main()
{
// Declare variables
string name;
int hours;
int DEDUCTION = 45;
int gross;
int net;
int rate;
string EOFNAME = "quit";
char again = 'Y';
// Declare input items
cout << "Enter first name or " << EOFNAME << " to quit ";
cin >> name;
if (name == EOFNAME) {
cout << "End of program ";
return 0;
} else {
cout << "Enter hours worked for " << name << endl;
cin >> hours;
cout << "Enter hourly rate for " << name << endl;
cin >> rate;
gross = hours * rate;
net = gross - DEDUCTION;
}
do {
cout << "Net pay for " << name << " is " << net << endl;
break;
} while (net > 0);
{
if (net < 0)
cout << "Deductions not covered. Net is 0." << endl;
}
return 0;
} // end of main