Computer Applications

A company announces revised Dearness Allowance (DA) and Special Allowances (SA) for their employees as per the tariff given below:

BasicDearness Allowance (DA)Special Allowance (SA)
Up to ₹ 10,00010%5%
₹ 10,001 - ₹ 20,00012%8%
₹ 20,001 - ₹ 30,00015%10%
₹ 30,001 and above20%12%

Write a program to accept name and Basic Salary (BS) of an employee. Calculate and display gross salary.

Gross Salary = Basic + Dearness Allowance + Special Allowance

Print the information in the given format:

Name    Basic    DA    Spl. Allowance    Gross Salary
  xxx        xxx      xxx            xxx                      xxx

Java

Java Conditional Stmts

136 Likes

Answer

import java.util.Scanner;

public class KboatSalary
{
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter name: ");
        String name = in.nextLine();
        System.out.print("Enter basic salary: ");
        double bs = in.nextDouble();
        double da = 0.0, sa = 0.0;

        if (bs <= 10000){
            da = bs * 10.0 / 100.0;
            sa = bs * 5.0 / 100.0;
        }
        else if (bs <= 20000){
            da = bs * 12.0 / 100.0;
            sa = bs * 8.0 / 100.0;
        }
        else if (bs <= 30000){
            da = bs * 15.0 / 100.0;
            sa = bs * 10.0 / 100.0;
        }
        else{
            da = bs * 20.0 / 100.0;
            sa = bs * 12.0 / 100.0;
        }
        
        double gs = bs + da + sa;
        System.out.println("Name\tBasic\tDA\tSpl. Allowance\tGross Salary");
        System.out.println(name + "\t" + bs + "\t" + da + "\t" + sa + "\t" + gs);
    }
}

Variable Description Table

Program Explanation

Output

Answered By

63 Likes


Related Questions