Java Chapters

Java program to calculate gross salary of an employee, dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary.

Structure of JAVA Programs - Overview
import java.util.Scanner;

public class Program 
{
    public static void main( String[] args ) 
    {
        double Basic_Salary, DA, HRA, Gross_Salary;
        Scanner reader = new Scanner(System.in);
        
        System.out.println("Enter Basic Salary : ");
        Basic_Salary = reader.nextDouble();
        
        DA = (Basic_Salary * 40) / 100;
        HRA = (Basic_Salary * 20) / 100;
        Gross_Salary = Basic_Salary + DA + HRA;
        
        System.out.println("\nDearness Allowance 40 % of Basic Salary : " + DA);
        System.out.println("House Rent 20 % of Basic Salary : " + HRA);
        System.out.println("Gross Salary : " + Gross_Salary);
    }
}

Output :
Enter Basic Salary : 20000

Dearness Allowance 40 % of Basic Salary : 8000
House Rent 20 % of Basic Salary : 4000
Gross Salary : 32000

Leave a comment
Recent Comments
  • vivek daniyal at 23-10-2018 09:57:00 AM
    its very useful.. need more program as it.