Write a program, which calculates and prints the House Rent Allowance (HRA) and Dearness Allowance (DA) of an employee. The basic salary (BS) of an employee is given as argument of a method. If (BS) is more than 10000; then,HRA is 85% of the BS. If BS is less than 10000; then, HRA is 100% of the BS. DA is 45% of the BS. Solve it by scanner class
Answers
Answered by
15
Answer:
import java.util.Scanner;
public class Employee
{
public static void main(String args[])
{
Scanner sc=new Scanner (System.in);
double b,hra,da=0;
System.out.println("Enter the basic salary of an employee:");
b=sc.nextInt();
if(b>10000)
{
hra=(85*b)/100;
System.out.println("House rent allowance:"+hra);
}
else
{
hra=(100*b)/100;
da=(45*b)/100;
System.out.println("House rent allowance:"+hra);
System.out.pritnln("Dearness allowance:"+da);
}
}
}
Hey mate you haven't given the percentage of DA if basic salary is ore than 10000. So I have nit included that part.
Similar questions