Write a Java program to calculate the gross salary of an employee, if basic salary of that employee is greater or equal to 20000 and year's of service is equal or greater than 5 years bonus will be 2000 else1000, TA =10%, DA= 20% and HRA=5% of salary.

import java.util.Scanner;

public class GrossSalaryCalculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter the basic salary of the employee: ");
        double basicSalary = scanner.nextDouble();

        System.out.print("Enter the years of service of the employee: ");
        int yearsOfService = scanner.nextInt();

        double bonus = (basicSalary >= 20000 && yearsOfService >= 5) ? 2000 : 1000;
        double ta = 0.10 * basicSalary;
        double da = 0.20 * basicSalary;
        double hra = 0.05 * basicSalary;

        double grossSalary = basicSalary + ta + da + hra + bonus;

        System.out.println("Gross Salary of the employee: " + grossSalary);
    }
}

Comments

Popular posts from this blog

Java program to implement file input stream class to read binary data from image file.

Java program to find length of given string and convert it in to upper or lower case.

Java program to read a text file and displays it's contents on screen.

Java program to check marks out of Bound exception.

Java program to calculate area and perimeter of circle using interfaces.

Java program to check greatest among three numbers where input numbers are given by user.

Java program to merge two text files in to third file.

Java Applet program to draw rectangle and right-aligned oval of orange color.

Concatenating and Buffering Files in Java जावा में फ़ाइलों को जोड़ना और बफर करना