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
|
#include <iostream>
using namespace std;
void getEmpData (string& name, float& hours, float& rate, float& overtimeRate);
float calEmpPay (float hours, float rate, float overtimeRate);
void dispEmplPay (string& name, float& pay);
int main()
{
string name = "";
float hours = 0;
float rate = 0;
float overtimeRate = 0;
float pay = 0;
getEmpData (name, hours, rate, overtimeRate);
pay = calEmpPay (hours, rate, overtimeRate);
dispEmplPay (name, pay);
system("pause");
return 0;
}
void getEmpData (string& name, float& hours, float& rate, float& overtimeRate)
{
cout << "What is your name?";
cin >> name;
cout << "How many hours did you work? ";
cin >> hours;
cout << "How much do you get paid per hour? ";
cin >> rate;
cout << "How much do you get paid per hour overtime?";
cin >> overtimeRate;
cout << endl;
}
float calEmpPay (float hours, float rate, float overtimeRate)
{
float pay;
if (hours <= 40)
pay = (hours * rate);
else
pay = (40 * rate) + (hours - 40)*overtimeRate;
return pay;
}
void dispEmplPay (string& name, float& pay)
{
cout << name << ", You have earned $" << pay << endl;
}
|