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 218 219 220 221 222 223 224 225
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
double grossPay, ytdcomp, medicare, social, state, federal;
double exemptCalc();
double nonexemptCalc();
double socialCalc();
double medicareCalc();
double federalCalc();
double stateCalc();
int main()
{
double ExPayGross,nonExPayGross;
int ssNum;
string employee;
char status;
cout << "Please enter the first name of the Employee: ";
cin >> employee;
cout << "\nPlease enter the employee's social security number: ";
cin >> ssNum;
cout << "\nPlease enter if the employee is exempt or non-exempt,\n'e' for exempt or 'n' for nonexempt: ";
cin >> status;
cout << "\nPlease enter the employee's year to date compensation: ";
cin >> ytdcomp;
switch (status)
{
case 'E':
case 'e':
cout << "\nThe Employee's Name is: " << employee;
cout << "\nThe Employee's Social Security Number is: " << social;
cout << "\nThe Employee's status is: Exempt ";
cout << fixed << showpoint;
cout << setprecision(2);
ExPayGross = exemptCalc();
medicare = medicareCalc();
social = socialCalc();
state = stateCalc();
federal = federalCalc();
cout << "\nThe Medicare Tax is: $" << medicare;
cout << "\nThe Social Tax is: $" << social;
cout << "\nThe State Tax is: $" << state;
cout << "\nThe Federal Tax is: $" << federal;
cout << "\nThe Employee's Gross Salary is: $" << (ExPayGross) - (medicare + social + state + federal);
cout << endl;
break;
case 'N':
case 'n':
cout << "\nThe Employee's Name is: " << employee;
cout << "\nThe Employee's Social Security Number is: " << social;
cout << "\nThe Employee's status is: Non-Exempt ";
nonExPayGross = nonexemptCalc();
medicare = medicareCalc();
social = socialCalc();
state = stateCalc();
federal = federalCalc();
cout << "\nThe Medicare Tax is: $" << medicare;
cout << "\nThe Social Tax is: $" << social;
cout << "\nThe State Tax is: $" << state;
cout << "\nThe Federal Tax is: $" << federal;
cout << "\nThe Employee's Gross Salary is: $" << (nonExPayGross) - (medicare + social + state + federal);
cout << endl;
break;
}
return 0;
}
double exemptCalc()
{
double grossPay, wklyComp;
cout << "\nPlease enter the employee's weekly salary: ";
cin >> wklyComp;
cout << endl;
grossPay = wklyComp;
return grossPay;
}
double nonexemptCalc()
{
double hourly_pay, hours_worked, hourly_rate, totalRegPay, overtime_rate,
overtime_pay, totalPay, regular_rate;
cout << "\nPlease enter the employee's hourly rate of pay: ";
cin >> hourly_rate;
cout << "\nPlease enter the employee's hours worked: ";
cin >> hours_worked;
hourly_pay = hours_worked * hourly_rate;
totalRegPay = hourly_pay + ytdcomp;
if (hours_worked <= 40)
{
totalPay = totalRegPay;
}
else if (hours_worked > 40)
{
regular_rate = totalRegPay/hours_worked;
overtime_rate = regular_rate * 0.5;
overtime_pay = (hours_worked - 40) * overtime_rate;
totalPay = totalRegPay + overtime_pay;
}
return totalPay;
}
double socialCalc()
{
double social, ss_exempt_amt, ss_taxable_amt;
const double ssa_wage_base = 113700.00;
if (ytdcomp > ssa_wage_base)
social = 0;
else if ((ytdcomp + grossPay) <= ssa_wage_base)
social = grossPay * .062;
else if ((ytdcomp + grossPay) > ssa_wage_base)
{
ss_exempt_amt = ytdcomp + grossPay - ssa_wage_base;
ss_taxable_amt = grossPay - ss_exempt_amt;
social = ss_taxable_amt * .062;
}
return social;
}
double medicareCalc()
{
double medicare, extraMedTaxAmount, regMedTaxAmount;
const double med_threshold = 200000.00;
const double med_extra = 0.009;
if (ytdcomp > med_threshold)
medicare = grossPay * (.0145 + med_extra);
else if ((ytdcomp + grossPay) <= med_threshold)
medicare = grossPay * .0145;
else if ((ytdcomp + grossPay) > med_threshold)
{
extraMedTaxAmount = ytdcomp + grossPay - med_threshold;
regMedTaxAmount = grossPay - extraMedTaxAmount;
medicare = regMedTaxAmount * .0145;
medicare = medicare + (extraMedTaxAmount * (.0145 + med_extra));
}
return medicare;
}
double stateCalc()
{
double state;
if (grossPay <= 1000)
state = (.05 * 1000);
else if (grossPay > 1000)
state = (.08) * (grossPay - 1000) + (.05 * 1000);
return state;
}
double federalCalc()
{
double federal;
if (grossPay <= 1000)
federal = (.10 * 1000);
else if (grossPay <= 2500)
federal = (.15) * (grossPay - 1000) + (.10 * 1000);
else if (grossPay > 2500)
federal = (.25) * (grossPay - 2500) + (.15) * (grossPay - 1500) + (.10 * 1000);
return federal;
}
|