-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployeepay.cpp
More file actions
70 lines (52 loc) · 1.49 KB
/
employeepay.cpp
File metadata and controls
70 lines (52 loc) · 1.49 KB
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
/*
Jessica Viner
2345566
viner@chapman.edu
CPSC 298 - 07
Programming Assignment 1: The Basics
employeepay.cpp
*/
#include <iostream>
using namespace std;
int main(){
//pay rates
const float regRate = 16.0;
const float overRate = 1.5 * regRate; // overtime rate
//withheld values and taxes
const float ssTax = 0.06;
const float fedIncTax = 0.14;
const float stateIncTax = 0.05;
const float medInsuranceWH = 10.0;
//input value
int hoursWorked;
//output values:
//tax withholdings
float ssTaxWH;
float fedIncTaxWH;
float stateIncTaxWH;
//gross and net take-home pay
float grossPay;
float netPay;
cout << "Hours worked in given week: ";
cin >> hoursWorked;
cout << endl;
if(hoursWorked <= 40){
grossPay = regRate * hoursWorked;
}else{
grossPay = regRate * 40;
grossPay = grossPay + ((hoursWorked - 40) * overRate);
}
cout << "Gross pay for the week: $"<< grossPay << endl << endl;
//calculations for the tax withholding
ssTaxWH = grossPay * ssTax;
fedIncTaxWH = grossPay * fedIncTax;
stateIncTaxWH = grossPay * stateIncTax;
cout << "Witholdings: " << endl;
cout << "Social Security Tax: $" << ssTaxWH << endl;
cout << "Federal Income Tax: $" << fedIncTaxWH << endl;
cout << "State Income Tax: $" << stateIncTaxWH << endl;
cout << "Medical Insurance: $" << medInsuranceWH << endl;
netPay = grossPay - ssTaxWH - fedIncTaxWH - stateIncTaxWH - medInsuranceWH;
cout << endl << "Net take-home pay: $" << netPay << endl;
return 0;
}