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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
//
//BEGIN
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
string getUserName();
double getPayRate();
double getTotalPay();
double getGrossPay(double GrossPay);
double getStateTax(double StateTax);
double getFederalTax(double FederalTax);
double getHoursOfTheWeek(double HoursOfTheWeek);
double getFICA(double FICA);
double getWithHoldingAmount(double WithHolding);
void displayAmountDue(string UserName,double GrossPay,double WithHolding,double NetPay);
int main()
{
string UserName;
double PayRate, TotalPay, GrossPay, StateTax, FederalTax, FICA, WithHolding;
//Get users name
UserName = getUserName();
//Get hourly pay rate
PayRate = getPayRate();
//Get Hours of the week
TotalPay = getHoursOfTheWeek(TotalPay);
//Calculate gross pay
GrossPay = getGrossPay(GrossPay);
//Calculate state tax
StateTax = getStateTax(StateTax);
//Calculate federal tax
FederalTax = getFederalTax(FederalTax);
//Calculate FICA tax
FICA = getFICA(FICA);
//Calculate WithHolding amount
WithHolding = getWithHoldingAmount(WithHolding);
//Display results
displayAmountDue(UserName, GrossPay, WithHolding, NetPay);
return 0;
}
string getUserName()
{
string UserName;
cout<<"Please enter your name: ";
cin>>UserName;
return UserName;
}
double getPayRate()
{
double PayRate;
cout<<"Please enter your hourly pay: ";
cin>>PayRate;
return PayRate;
}
double getHoursOfTheWeek(int workDay, int TotalHours)
{
int m;
cout<<"How many days have you worked this week?";
cin>>workDay;
if (workDay == 1)
{
cout<<"Please enter the amount of hours you have worked on Monday: ";
cin>>m;
TotalHours = m;
cout<<"Your total hours are: "<<TotalHours<<endl;
return TotalHours;
}
else if (workDay == 2)
{
int m, t;
cout<<"Please enter the amount of hours you have worked on Monday: ";
cin>>m;
cout<<"Please enter the amount of hours you have worked on Tuesday: ";
cin>>t;
TotalHours = m+t;
cout<<"Your total hours are: "<<TotalHours<<endl;
return TotalHours;
}
else if (workDay ==3)
{
int m, t, w;
cout<<"Please enter the amount of hours you have worked on Monday: ";
cin>>m;
cout<<"Please enter the amount of hours you have worked on Tuesday: ";
cin>>t;
cout<<"Please enter the amount of hours you have worked on Wednesday: ";
cin>>w;
TotalHours = m+t+w;
cout<<"Your total hours are: "<<TotalHours<<endl;
return TotalHours;
}
else if (workDay ==4)
{
int m, t, w, th;
cout<<"Please enter the amount of hours you have worked on Monday: ";
cin>>m;
cout<<"Please enter the amount of hours you have worked on Tuesday: ";
cin>>t;
cout<<"Please enter the amount of hours you have worked on Wednesday: ";
cin>>w;
cout<<"Please enter the amount of hours you have worked on Thursday: ";
cin>>th;
TotalHours = m+t+w+th;
cout<<"Your total hours are: "<<TotalHours<<endl;
return TotalHours;
}
else if (workDay ==5)
{
int m, t, w, th, f;
cout<<"Please enter the amount of hours you have worked on Monday: ";
cin>>m;
cout<<"Please enter the amount of hours you have worked on Tuesday: ";
cin>>t;
cout<<"Please enter the amount of hours you have worked on Wednesday: ";
cin>>w;
cout<<"Please enter the amount of hours you have worked on Thursday: ";
cin>>th;
cout<<"Please enter the amount of hours you have worked on Friday: ";
cin>>f;
TotalHours = m+t+w+th,f;
cout<<"Your total hours are: "<<TotalHours<<endl;
return TotalHours;
}
}
double GetGrossPay(double TotalHours, double PayRate)
{
double GrossPay;
GrossPay = TotalHours * PayRate;
return GrossPay;
}
double GetStateTax(double GrossPay)
{
double StateTax;
StateTax = GrossPay * 1.25;
return StateTax;
}
double GetFederalTax(double GrossPay)
{
double amount, FederalTax;
if (GrossPay<500)
{
amount = GrossPay * .15;
}
else
{
amount = GrossPay * .25;
}
return FederalTax;
}
double GetFica(double GrossPay)
{
double FICA;
FICA = GrossPay * 7.65;
return FICA;
}
double getWithHoldingAmount(double WithHolding, double StateTax, double FederalTax, double FICA)
{
WithHolding = StateTax + FederalTax + FICA;
return WithHolding;
}
void displayAmountDue(string UserName, double GrossPay, double WithHolding))
{
cout<< "UserName: "<<UserName<<endl;
cout<< "Gross Pay: "<<GrossPay<<endl;
cout<< "Total Withholding amount: "<<WithHolding<<endl;
}
//END
|