Sunday 16 August 2015

WAP in java to accept employee no and basic salary,and to calculate gross salary depending upon following conditions:1)If basic salary>5000 then HRA=5%,DA=8%,TA=500 2)If basic salary>2000 then HRA=4%,DA=6%,TA=300 otherwise HRA,DA,TA are not given.

//Employee no and salary calculations
import java.util.Scanner;

class Employee {

public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter employee no and basic salary:");
int eid=sc.nextInt();
float bs=sc.nextFloat();

float hra,da,ta,gs;

if(bs>5000)
{
hra=0.05f*bs;
da=0.08f*bs;
ta=500;
}
else if(bs>2000)
{
hra=0.04f*bs;
da=0.06f*bs;
ta=300;
}
else
hra=da=ta=0;

gs=bs+hra+da+ta;
System.out.println("Employee no:"+eid+" Gross Salary:"+gs);

}

}

No comments:

Post a Comment