Java program to calculate gross salary of an employee

Ex: Write a java program to calculate gross salary of an employee. How to write a java program to calculate gross salary of an employee using DA and HRA. Java program to calculate gross salary of an employee using DA and HRA.  

We can calculate gross salary   of an  employee using following DA and HRA. The  DA is   20%   of   the   basic   salary   while   the   HRA   is   30%   of   the   basic salary and gross salary is addition of basic salary, DA and HRA.


Program to calculate gross salary of an employee:

import java.util.Scanner;

public class GrossSalary {


    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        float b;
        float da;
        float hra;
        float gross;

        System.out.println("Enter the basic salary of an employee:");
        b = sc.nextFloat();

        da = (b * 20) / 100;
        hra = (b * 30) / 100;

        gross= b + da + hra;

        System.out.println("Gross salary of an employee is: " +gross);

    }
}
Above java program shows the following output:

Enter the basic salary of an employee:  15000

Gross salary of an employee is: 22500.0

No comments:

Post a Comment

If you have any doubts, please discuss here...👇