Java Program to calculate Salary of an Employee

Program

import java.util.*;
public class EmpSalary
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter the basic pay");
		int basic = sc.nextInt();
		Salary sal = new Salary();
		sal.calculateTotal(basic);
	}
}
class Salary
{
	private double da;
	private double hra;
	private double oth;
	void calculateTotal(int basic)
	{
		da = 0.90 * basic;
		hra = 0.20 * basic;
		oth = 0.10 * basic;
		double total = basic + da + hra + oth;
		System.out.println("Basic Salary:\t" + basic);
		System.out.println("Dearness Allowance:\t" + da);
		System.out.println("House Rent Allowance:\t" + hra);
		System.out.println("Other Allowances:\t" + oth);
		System.out.println("Total Salary is: " + total);
	}
}

Output

Enter the basic pay
25000
Basic Salary:	25000
Dearness Allowance:	22500.0
House Rent Allowance:	5000.0
Other Allowances:	2500.0
Total Salary is: 55000.0