Aanchal’s basic salary is input through the keyboard. Her dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write Java program to calculate his gross salary.

Explanation:

Aanchal’s basic salary is let us say 20,000 here, her dearness allowance(da) is 40% of basic salary, and house rent allowance(hra) is 20% of basic salary. Now we have to calculate her gross salary using java program coding.
Here’s how:

Coding:


package simplearithmetic;



//Aanchal’s basic salary is 20000 here, her
//dearness allowance(da) is 40% of basic salary, 
//and house rent allowance(hra) is 20% of basic salary//


public class Ramesh's Gross Salary {
    public static void main(String[] args) {
        
        double basicsalary=20000;
        double da=40*basicsalary/100.0;
        double hra=20*basicsalary/100.0;
        double grosssalary=basicsalary+da+hra;
        System.out.print("Gross Salary Of Ramesh = ");
        System.out.println(grosssalary);
        
    }
    
}

Output:

 

Leave a Reply