-
Notifications
You must be signed in to change notification settings - Fork 0
/
TotalSalary.java
51 lines (45 loc) · 1.48 KB
/
TotalSalary.java
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
// 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), depending upon which the total salary is calculated as:
//
// Total_salary = 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 for C++ users :
//
// To round off the value, please include<cmath> library at the start of the program and round off the values in this way.
// int ans = round(yourFinalValue);
import java.util.Scanner;
import java.lang.Math;
public class Solution{
public static void main(String[] args) {
//Write your code here.
Scanner sc=new Scanner(System.in);
int basic=sc.nextInt();
char grade=sc.next().charAt(0);
int a= basic;
int allow=1300;
double hra=(0.2d*basic);
double da=(0.5d*basic);
if(grade=='A')
{
allow=1700;
}else if(grade=='B')
{
allow=1500;
}
double pf=(0.11d*basic);
double totalSalary=a+hra;
totalSalary+=da;
totalSalary+=allow;
totalSalary-=pf;
System.out.println(Math.round(totalSalary));
}
}