1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
int hours_1, hours_2, hours_3, hours_4, hours_5, total_hours, avg_pay_rate, total_pay1, total_pay2, total_pay3, total_pay4, total_pay5;
double pay_rate1, pay_rate2, pay_rate3, pay_rate4, pay_rate5, total_pay_rate;
// hours worked
cout << "Hours worked by employee #1 : ";
cin >> hours_1;
cout << "Hours worked by employee #2 : ";
cin >> hours_2;
cout << "Hours worked by employee #3 : ";
cin >> hours_3;
cout << "Hours worked by employee #4 : ";
cin >> hours_4;
cout << "Hours worked by employee #5 : ";
cin >> hours_5;
//total hours worked
total_hours = hours_1 + hours_2 + hours_3 + hours_4 + hours_5;
// hourly pay rate for employees
cout << "Hourly pay rate for employee #1 : ";
cin >> pay_rate1;
cout << "Hourly pay rate for employee #2 : ";
cin >> pay_rate2;
cout << "Hourly pay rate for employee #3 : ";
cin >> pay_rate3;
cout << "Hourly pay rate for employee #4 : ";
cin >> pay_rate4;
cout << "Hourly pay rate for employee #5: ";
cin >> pay_rate5;
// Average pay rate
avg_pay_rate = (pay_rate1 + pay_rate2 + pay_rate3 + pay_rate4 + pay_rate5 / 5.0;
//Calculate total Pay
total_pay1 = hours_1 * pay_rate1;
total_pay2 = hours_2 * pay_rate2;
total_pay3 = hours_3 * pay_rate3;
total_pay4 = hours_4 * pay_rate4;
total_pay5 = hours_5 * pay_rate5;
// Total pay rates
total_pay_rate = total_pay1 + total_pay2 + total_pay3 + total_pay4 + total_pay5;
// the total of all the pay rates
total_pay_rate = total_pay1 + total_pay2 + total_pay3 + total_pay4 + total_pay5;
//Display the table
cout << "\nEmployee# Hours Pay Rate Total Pay\n";
cout << "===============================================\n";
// Display the rows
cout << setw(6) << "1" << setw(10)
<< pay_rate1 << setw(10) << "$" << total_pay1 << endl;
cout << setw(6) << "2" << setw(10)
<< pay_rate2 << setw(10) <<" $" << total_pay2 << endl;
cout << setw(6) << "3" << setw(10)
<< pay_rate3 << setw(10) <<" $" << total_pay3 << endl;
cout << setw(6) << "4" << setw(10)
<< pay_rate4 << setw(10) <<" $" << total_pay4 << endl;
cout << setw(6) << "5" << setw(10)
<< pay_rate5 << setw(10) <<" $" << total_pay5 << endl;
cout << "Total/Average" << setw(3) << total_hours << setw(12)
<< total_pay_rate << endl;
system("pause");
}
|