// pgm13 -- modified employee program with // structured read loop // also, we are going to count how many employees there are // 9/21/16 #include #include using namespace std; int main() { // define variables string first, last; int idnum; double rate,hours,pay; // read in data for a fixed number of employees int numemps=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; 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; return 0; }