// pgm28 -- modified employee program with // ARRAYS // 11/7/16 #include #include using namespace std; const int SIZE=150; int main() { // define variables int idnum[SIZE]; double rate[SIZE], hours[SIZE], pay[SIZE]; // 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[numemps]; // reads in loc 0 while (idnum[numemps] != -1) { // process previous employee cout << "Enter employee #" << idnum[numemps] << " hours worked and rate of pay: "; cin >> hours[numemps] >> rate[numemps]; // calculate pay pay[numemps] = hours[numemps] * rate[numemps]; // print everything cout << "id: " << idnum[numemps] << " Hours: " << hours[numemps] << " rate: " << rate[numemps] << endl; total+=pay[numemps]; cout << "pay for employee " << numemps+1 << " is: " << pay[numemps] << endl; numemps++; // read next employee cout << "Enter id number, -1 to exit: "; cin >> idnum[numemps]; } // 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; // GAIN with Arrays: The data is all in memory // ex: who worked the most hours? // this is a findmax question in the hours array double maxHours=hours[0]; int index = 0; // index is the index of maxHours in the hours array for (int i=1; i