Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double calcGrossPay(int hours, double rate)
- {
- double grossPay = 0.0;
- double overtimePay = 0.0;
- if (hours > 40) {
- hours = hours - 40;
- overtimePay = hours * (rate * 1.5);
- }
- grossPay = hours*rate + overtimePay;
- return grossPay;
- }
- double calcTotal(double current, double pay)
- {
- double total = 0.0;
- total = current + pay;
- return total;
- }
- int main()
- {
- int hours = 0;
- int employee = 0;
- double rate = 0.0;
- double current = 0.0;
- double totalGrossPay = 0.0;
- double pay = 0.0;
- while(1){
- employee++;
- cout << "Enter Total hours worked for employee " << employee << ", -1 to cancel: " << endl;
- cin >> hours;
- if(hours==-1)
- break;
- cout << "Enter rate of pay for this employee: " << endl;
- cin >> rate;
- current = calcGrossPay(hours, rate);
- cout << "This employee's gross pay is: $" << current << endl;
- totalGrossPay += calcTotal(current, pay);
- }
- cout << "The total gross pay of all " << employee << " employee's is : $" << totalGrossPay << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement