-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathTotalSalary.cpp
61 lines (54 loc) · 1.39 KB
/
TotalSalary.cpp
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
Total Salary
Write a program to calculate the total salary of a person. The user has to enter the basic salary (an integer) and the grade (an uppercase character), and depending upon which the total salary is calculated as -
totalSalary = basic + hra + da + allow – pf
where :
hra = 20% of basic
da = 50% of basic
allow = 1700 if grade = ‘A’
allow = 1500 if grade = ‘B’
allow = 1300 if grade = ‘C' or any other character
pf = 11% of basic.
Round off the total salary and then print the integral part only.
Note: Try finding out a function on the internet to do so
Input format :
Basic salary & Grade (separated by space)
Output Format :
Total Salary
Constraints :
0 <= Basic Salary <= 7,500,000
Sample Input 1 :
10000 A
Sample Output 1 :
17600
Sample Input 2 :
4567 B
Sample Output 2 :
8762
/************************************************** SOLUTION *****************************************************************************/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double bsal;
char grade;
cin>>bsal>>grade;
double totalsal1;
double totalsal;
double hra = (0.20*bsal);
double da = (0.50*bsal);
double pf= (0.11*bsal);
double allow;
if(grade=='A'){
allow = 1700;
}
else if(grade=='B'){
allow = 1500;
}
else{
allow = 1300;
}
totalsal1=(bsal+hra+da+allow);
totalsal=totalsal1-pf;
cout<<llround(totalsal);
}