Total Salary
Send Feedback
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 -
where :
Round off the total salary and then print the integral part only.
Input format :
Output Format :
Sample Input 1 :
Sample Output 1 :
Sample Input 2 :
Sample Output 2 :
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[] args)
- {
- double t_sal,allow;
- Scanner s = new Scanner(System.in);
- //System.out.println("enter the basis amount of salary");
- double basic = s.nextInt();
- //System.out.println("enter any chr for give grade");
- char grade = s.next().charAt(0);
- double hra = ((basic*20/100.0));
- // System.out.println("hra is "+hra);
- double da = ((basic*50/100.0));
- // System.out.println("da is "+da);
- double pf = ((basic*11/100.0));
- // System.out.println("pf is "+pf);
- if(grade == 'A')
- {
- allow = 1700;
- }
- else if(grade == 'B')
- {
- allow = 1500;
- }
- else
- {
- allow = 1300;
- }
- t_sal = basic + hra + da + allow - pf;
- //System.out.println("total salary is "+t_sal);
- System.out.println(Math.round(t_sal));
- }
- }
We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
ReplyDeleteand friends also message me on instagram ( https://www.instagram.com/dvlpr.u/ )
MY OUTPUT IS COMING 17200
ReplyDelete