Given the basic salary of a person the task is to calculate the gross salary if the company gives Dearness Allowance and Special Allowance as per the given tariff.
| Basic | Dearness Allowance (DA) | Special Allowance (SA) |
| First ₹1 to ₹10000 | 10% | 5% |
| Next ₹10001 to ₹20000 | 12% | 8% |
| Next ₹20001 to ₹30000 | 15% | 10% |
| More than ₹30000 | 20% | 12% |
Java
import java.util.*;
public class GrossSalarySlab
{
public static void main(String args[])
{
double bSalary=0.0,gSalary=0.0,da=0.0,sa=0.0;
Scanner sc=new Scanner(System.in);
System.out.print("Basic Salary: ");
bSalary=sc.nextInt();
if(bSalary<=10000)
{
da=0.1*bSalary;
sa=0.05*bSalary;
gSalary=bSalary+da+sa;
}
else if(bSalary>10000&&bSalary<=20000)
{
da=((10000-0)*0.1)+((bSalary-10000)*0.12);
sa=((10000-0)*0.05)+((bSalary-10000)*0.08);
gSalary=bSalary+da+sa;
}
else if(bSalary>20000&&bSalary<=30000)
{
da=((10000-0)*0.1)+((20000-10000)*0.12)+((bSalary-20000)*0.15);
sa=((10000-0)*0.05)+((20000-10000)*0.08)+((bSalary-20000)*0.1);
gSalary=bSalary+da+sa;
}
else
{
da=((10000-0)*0.1)+((20000-10000)*0.12)+((30000-20000)*0.15)+((bSalary-30000)*0.2);
sa=((10000-0)*0.05)+((20000-10000)*0.08)+((30000-20000)*0.1)+((bSalary-30000)*0.12);
gSalary=bSalary+da+sa;
}
System.out.println("Dearness Allowance: Rs "+da);
System.out.println("Special Allowance : Rs "+sa);
System.out.println("Gross Salary: Rs "+gSalary);
}
}Java