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) |
| Upto ₹10000 | 10% | 5% |
| From ₹10001 to ₹20000 | 12% | 8% |
| From ₹20001 to ₹30000 | 15% | 10% |
| ₹30001 and above | 20% | 12% |
Java
import java.util.*;
public class GrossSalary
{
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=0.12*bSalary;
sa=0.08*bSalary;
gSalary=bSalary+da+sa;
}
else if(bSalary>20000&&bSalary<=30000)
{
da=0.15*bSalary;
sa=0.1*bSalary;
gSalary=bSalary+da+sa;
}
else
{
da=0.2*bSalary;
sa=0.12*bSalary;
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