Total Salary
Total Salary
Send Feedback
Total Salary
totalSalary = basic + hra + da + allow – pf
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.
Basic salary & Grade (separated by space)
Total Salary
0 <= Basic Salary <= 7,500,000
10000 A
17600
4567 B
8762
We have been given the basic salary as Rs. 4567. We need to calculate the hra, da and pf.
Now when we calculate each of the, it turns out to be:
hra = 20% of Rs. 4567 = Rs. 913.4
da = 50% od Rs. 4567 = Rs. 2283.5
pf = 11% of Rs. 4567 = Rs. 502.37
Since, the grade is 'B', we take allowance as Rs. 1500.
On substituting these values to the formula of totalSalary, we get Rs. 8761.53 and now rounding it off will result in Rs. 8762 and hence the Answer.
// #include<iostream>// #include<bits/stdc++.h>// using namespace std;
// int main() {// // Write your code here// int basic;// float hra,allow,pf,da;// cin>>basic;// hra=basic*0.2;// da=basic*0.5;// pf=basic*0.11;// char grade;// cin>>grade; // if(grade=='A'){// allow=1700;// }// else if(grade=='B'){// allow=1500;// } // else{// allow=1300;// }// double totalsalary=basic+hra+da+allow-pf;// cout<<lround(totalsalary); // }
#include <iostream>#include<bits/stdc++.h>using namespace std;int main(int argc, char** argv) { int basic; cin>>basic; float hra,da,allow,pf,totalsalary; hra=0.2*basic; da=0.5*basic; pf=0.11*basic; char ch; cin>>ch; if(ch=='A'){ allow=1700; } else if(ch=='B'){ allow='B'; } else{ allow=1300; } totalsalary=basic+hra+da+allow-pf; cout<<lround(totalsalary)<<endl; return 0;}
Comments
Post a Comment