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
|
#include<iostream>
using namespace std;
// void function declaration for User Input
void getUserInput_function(int hoursWorked, int dependents, int employmentStatus, double hourlyRate);
// void function declaration to calculate Overtime Pay
void calculateOvertimePay_function(int &hoursWorked, double &hourlyRate, double &basePay, int &overTimeHours, int &doubleTimeHours, double &overTimePay, double &grossPay, double &doubleTimePay);
// function declaration for IRA deposits
double IRA_function(double grossPay);
//function declaration for tax withholdings based on # of dependents
double withold_function(int &dependents, double modifiedGrossPay);
// function declaration to calculate medical benefit cost
double medical_cost_function(int &employmentStatus, double netPay, double &modifiedNetPay);
// function declaration for Payroll Output
double outputPayrollInfo_function (int hoursWorked, int overTimeHours, int doubleTimeHours, int dependents, double basePay, double grossPay, double &modifiedGrossPay, double &netPay, double modifiedNetPay, double overTimePay, double doubleTimePay, double &witholdCalc, double &iraDeductionAmount, double &medicalBenefitCost);
int main()
{
int hoursWorked, overTimeHours, doubleTimeHours, dependents, employmentStatus;
double hourlyRate, basePay, grossPay, netPay, overTimePay, doubleTimePay, modifiedGrossPay, modifiedNetPay, witholdCalc, iraDeductionAmount, medicalBenefitCost;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
overTimeHours = 0;
doubleTimeHours = 0;
// function call for User Input
getUserInput_function(hoursWorked, dependents, employmentStatus, hourlyRate);
// function call to calculate Overtime Pay
calculateOvertimePay_function(hoursWorked, hourlyRate, basePay, overTimeHours, doubleTimeHours, overTimePay, grossPay, doubleTimePay);
// function call to output Payroll Info
outputPayrollInfo_function(hoursWorked, overTimeHours, doubleTimeHours, dependents, basePay, grossPay, modifiedGrossPay, netPay, modifiedNetPay, overTimePay, doubleTimePay, witholdCalc, iraDeductionAmount, medicalBenefitCost);
// function call for IRA
iraDeductionAmount = IRA_function(grossPay);
modifiedGrossPay = grossPay - iraDeductionAmount; // modified gross pay calculation prior to tax
// function call for withholdings
witholdCalc = withold_function(dependents, modifiedGrossPay);
netPay = modifiedGrossPay - witholdCalc; // net pay calculation of modified gross pay
// function call for medical benefits
medicalBenefitCost = medical_cost_function(employmentStatus, netPay, modifiedNetPay);
modifiedNetPay = netPay - medicalBenefitCost; //net Pay adjusted for medical benefits
} // end of main
void getUserInput_function(int hoursWorked, int employmentStatus, int hourlyRate, double dependents)
{
cout << "Please enter your hourly rate of pay: $" << endl; //user inputs hourly rate
cin >> hourlyRate;
cout << "Please enter how the number of hours worked: " << endl; //user inputs number of hours worked
cin >> hoursWorked;
cout << "Please enter how many dependents you have: " << endl; //user inputs number of dependents
cin >> dependents;
cout << "Enter 1 if you are a full-time employee and 0 for part time: " <<endl; // user inputs employment status
cin >> employmentStatus;
}
// void - function to calculate Overtime Pay
void calculateOvertimePay_function(int &hoursWorked, double &hourlyRate, double &basePay, int &overTimeHours, int &doubleTimeHours, double &overTimePay, double &grossPay, double &doubleTimePay)
{
if (hoursWorked > 40) //calculating if hours are over 40
{
basePay = hourlyRate * 40;
overTimeHours = hoursWorked - 40;
}
if (overTimeHours > 10) //calculating overtime and double time hours
{
doubleTimeHours = overTimeHours - 10;
overTimeHours = 10;
doubleTimePay = hourlyRate * 2 * doubleTimeHours; // calculating rates for over and double time
overTimePay = hourlyRate * 1.5 * overTimeHours;
grossPay = basePay + overTimePay + doubleTimePay;
}
else //accounting for over time below 10 hours
{
basePay = (hoursWorked - overTimeHours) * hourlyRate;
overTimePay = overTimeHours * (hourlyRate * 1.5);
grossPay = basePay + overTimePay + doubleTimePay;
}
}
// IRA function definition. Calculates deduction based on gross pay
double IRA_function (double grossPay)
{
double iraDeductionAmount;
if(grossPay >= 500)
iraDeductionAmount = grossPay * 0.10;
else if (grossPay > 400)
iraDeductionAmount = grossPay * 0.05;
else
iraDeductionAmount = 0;
return(iraDeductionAmount);
}
// Withholding function definition. Calculates withholding based on # of dependents.
double withold_function (int &dependents, double modifiedGrossPay)
{
double subtotal;
double withold = 0;
if (dependents > 2)
withold = 0.15;
else if (dependents == 2)
withold = 0.18;
else if (dependents == 1)
withold = 0.2;
else if (dependents == 0)
withold = 0.28;
subtotal = modifiedGrossPay * withold;
return (subtotal);
}
// Medical benefit function definition. Calculates medical benefits costs based on employment status (1 for FT, 0 for PT)
double medical_cost_function(int &employmentStatus, double netPay, double &modifiedNetPay)
{
double medBenCost = 0;
if (employmentStatus == 1)
medBenCost = netPay * .07;
return (medBenCost);
}
double outputPayrollInfo_function(int hoursWorked, int overTimeHours, int doubleTimeHours, int dependents, double basePay, double grossPay, double &modifiedGrossPay, double &netPay, double modifiedNetPay, double overTimePay, double doubleTimePay, double &witholdCalc, double &iraDeductionAmount, double &medicalBenefitCost)
{
cout << "******************************************" << endl;
cout << " " << endl;
cout << "You worked " << hoursWorked << " hours total this pay period." << endl;
cout << overTimeHours << " hour(s) are paid at time and a half." << endl;
cout << doubleTimeHours << " hour(s) are paid at double time." << endl;
cout << " " << endl;
cout << "******************************************" << endl;
cout << " " << endl;
cout << "Your total base pay is: $" << basePay << endl;
cout << "Your overtime at time and a half is: $" << overTimePay << endl;
cout << "Your overtime at double time is: $" <<doubleTimePay << endl;
cout << "Your total gross pay with all overtime is: $" << grossPay << endl;
cout << " " << endl;
cout << "Your IRA deduction is: $" << iraDeductionAmount << endl;
cout << "Your modified gross pay is: $" << modifiedGrossPay << endl;
cout << " " << endl;
cout << "Your tax withholding amount with " << dependents << " dependent(s) is: $" << witholdCalc << endl; // amount of withholdings
cout << "Your modified net pay is now: $" << netPay << endl;
cout << " " << endl;
cout << "If you work full-time employee, you pay $" << medicalBenefitCost << " towards medical costs," <<endl;
cout << "so your adjusted net pay is now: $" << modifiedNetPay << endl;
return 0;
}
|