-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetPay_calculator.cpp
More file actions
55 lines (46 loc) · 947 Bytes
/
netPay_calculator.cpp
File metadata and controls
55 lines (46 loc) · 947 Bytes
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
/*
Author: CWN221
Date: 26/09/2024
Description: C++ Program to calculate gross pay, tax & net pay
RegNo: BSE-01-0032/2024
*/
#include <iostream>
using namespace std;
int main()
{
int hours;
float hWage, grossPay, tax, netPay;
//User Input
cout<<"Enter hours worked this week: "<<endl;
cin>>hours;
cout<<"Enter hourly wage: "<<endl;
cin>>hWage;
//Calculate Overtime
if (hours > 40)
{
//1. Pay the first 40 hours
grossPay = 40 * hWage;
// Overtime
grossPay += (hours - 40) * (hWage * 1.5);
}
else
{
grossPay = hours * hWage;
}
//Calculate Taxes
if (grossPay <= 600)
{
tax = grossPay * 0.15;
}
else if (grossPay > 600)
{
tax = (600 * 0.15) + ((grossPay - 600) * 0.20);
}
//Calculate Net Pay
netPay = grossPay - tax;
//Results
cout<<"Gross Pay: "<<grossPay<<endl;
cout<<"Tax: "<<tax<<endl;
cout<<"Net Pay: "<<netPay<<endl;
return 0;
}