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
|
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
void AskName(string&Yourname);
void AskRateAndHours(float&HourlyEarnings, float&HoursWorked, float&Grosspay, float&TotalHours, double&Overtime, double&Taxes1, double&Taxes2);
void WriteResults(string&Yourname, float&HourlyEarnings, float&HoursWorked, float&Grosspay, float&TotalHours, double&Overtime, double&Taxes1, double&Taxes2);
int main()
{
AskName(string&Yourname);
AskRateAndHours(float&HourlyEarnings, float&HoursWorked, float&Grosspay, float&TotalHours, double&Overtime, double&Taxes1, double&Taxes2);
WriteResults(Yourname,HourlyEarnings,HoursWorked,Grosspay, TotalHours,Overtime,Taxes1,Taxes2);
}
void AskName(string&Yourname)
{
cout << "What is your name?" << endl;
cin >> Yourname;
cout << "Welcome:" <<""<< Yourname << endl;
cout << setfill('-') << setw(50) << "-" << endl;
}
void AskRateAndHours(float&HourlyEarnings, float&HoursWorked, float&Grosspay, float&TotalHours, double&Overtime, double&Taxes1, double&Taxes2)
{
cout << "Enter your hourly earnings" << endl;
cin >> HourlyEarnings;
cout << "Enter your hours worked" << endl;
cin >> HoursWorked;
cout << setfill('-') << setw(50) << "-" << endl;
// assuming that 1 working week = 5 days. (Monday - Friday)
TotalHours = HoursWorked * 5;
Grosspay = (HourlyEarnings*HoursWorked) * 5;
Overtime = Grosspay*0.5;
Taxes1 = Grosspay*0.1;
Taxes2 = Grosspay*0.2;
cout << "This is your total pay per week:" << "" << Grosspay << "$" << endl << endl;
if (TotalHours > 40)
{
cout << "You are eligible for an added overtime bonus of:" << "" << Overtime << "$" << endl;
cout << "This ammount will be added to your wage" << endl << endl;
}
if (Grosspay < 250)
{
cout << "You do not have to pay any taxes" << endl;
}
else if (Grosspay <= 500)
{
cout << "However, you have to pay a 10% tax worth:" << "" << Taxes1 << "$" << endl << endl;
}
else if (Grosspay > 500)
{
cout << "However, you have to pay a 20% tax worth:" << "" << Taxes2 << "$" << endl << endl;
}
}
void WriteResults(string&Yourname, float&HourlyEarnings, float&HoursWorked, float&Grosspay, float&TotalHours, double&Overtime, double&Taxes1, double&Taxes2)
{
cout << "Here are your results:" << endl << endl;
cout << setfill('-') << setw(50) << "-" << endl;
cout << "Name:" << Yourname << endl;
cout << "Earnings per hour:" << HourlyEarnings <<"$"<< setprecision(2) << fixed << endl;
cout << "Hours worked each day:" << HoursWorked <<""<< endl;
cout << "Your total hours worked per week:" << TotalHours << endl;
cout << "Your Grosspay:" << Grosspay <<"$"<< setprecision(2) << fixed << endl;
cout << "Your Overtime bonus:" << Overtime <<"$"<< setprecision(2) << fixed << endl;
if (Grosspay < 250)
{
cout << "Your Taxes are:" << "0" << "$" << setprecision(2) << fixed << endl << endl << endl;
}
else if (Grosspay <= 500)
{
cout << "Your Taxes are:" << Taxes1 << "$" << setprecision(2) << fixed << endl << endl << endl;
}
else if (Grosspay > 500)
{
cout << "Your Taxes are:" << Taxes2 << "$" << setprecision(2) << fixed << endl << endl << endl;
}
system("pause");
}
| |