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
|
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;
void introduction ()
{
cout<< "Please enter the information required and I will calculate for you your Gross Pay. " ;
}
void getInput (string & name, double & hourly, double & totalHours)
{ cout<< "Please enter your name:" ;
cin>> name;
cout<< "What is your hourly wage? " ;
cin>> hourly;
cout << "How many hours did you work in total?" ;
cin>> totalHours;
}
double computeWage (double hourly, double totalHours)
{double grossPay;
if (totalHours > 40)
{grossPay = (hourly*40)+(totalHours-40)*hourly; }
else if (totalHours <= 40)
{grossPay = totalHours * hourly; }
return grossPay;
}
void displayEmpData (string name, double totalHours, double hourly, double grossPay)
{ cout<<endl;
cout<< "Employee Name " << " Total Hours " << "Hourly wage " << "Gross pay " ;
cout<<endl;
cout<< name << " " << totalHours<< " " << hourly << " " << grossPay;
}
int main()
{
string name;
double totalHours, hourly, grossPay;
introduction;
getInput (name, hourly, totalHours);
do {
grossPay = computeWage(hourly, totalHours);
displayEmpData(name, totalHours, hourly, grossPay);}
while (name =! NULL);
system ("pause");
return 0;
}
|