// pgm13 -- modified employee program with // structured read loop // count how many employees there are /* NEW for version e: sum the total amount paid over all employees */ // 9/28/16 #include #include using namespace std; int main() { // define variables string first, last; int idnum; double rate,hours,pay; // read in data for any number of employees // and keep a count in numemps int numemps=0, total=0; cout << "Enter id number, -1 to exit: "; cin >> idnum; while (idnum != -1) { cout << "Enter employee #" << idnum << " first name: "; cin >> first; cout << "Enter last name: "; cin >> last; cout << "Enter hours worked and rate of pay: "; cin >> hours >> rate; // calculate pay pay = hours * rate; // print everything cout << "Name: " << first << ' ' << last << " id: " << idnum << " Hours: " << hours << " rate: " << rate << endl; total+=pay; numemps++; cout << "pay for employee " << numemps << " is: " << pay << endl; cout << "Enter id number, -1 to exit: "; cin >> idnum; } // fell out of loop, print counter (numemps which is // number of employees processed.) cout << "Number of employees entered is: " << numemps << endl; cout << "Total pay is: " << total << endl; return 0; }