Program to find the total salary by hand of an Employee
Class 1 Get basic pay, deduction, and bonus from the console.
Class 2 Calculate hra (5% of basic pay) and pf (20% of basic pay).
Class 3 Find the total salary (basicpay+hra-pf-deduction+bonus) and get the salary slip
Salary slip should contains :- basic pay, deduction, hra, pf, bonus and total salary by hand.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double basicPay = in.nextDouble();
double deduction = in.nextDouble();
double bonus = in.nextDouble();
double hra = basicPay * 0.05;
double pf = basicPay * 0.2;
double totalSalary = basicPay + hra - pf - deduction + bonus;
System.out.println( "basic pay: " + basicPay +
"\ndeduction: " + deduction +
"\nhra: " + hra +
"\npf: " + pf +
"\nbonus: " + bonus +
"\n total salary: " + totalSalary);
}
}
Comments
Leave a comment