Write a program in Java to input the name and basic salary of an
employee. Calculate and display the gross salary and net salan
when:
da= 30% of basic
hra= 12.5% of basic
pf= 10% of basic
gross= basic + da + hra
net pay = gross - pf
using scanner class only
no spam
it's urgent please give fast
Answers
Answer:-
This is the required program.
import java.util.*;
class Program
{
public static void main()
{
double basic, da, hra, pf, gross, net_pay;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the basic salary: ");
basic=sc.nextDouble();
da=30/100.0*basic;
hra=12.5/100.0*basic;
pf=10/100.0*basic;
gross=basic+da+hra;
net_pay=gross-pf;
System.out.println("Gross salary: "+gross);
System.out.println("Net salary: "+net_pay);
}
}
Answer:
Answer:-
This is the required program.
import java.util.*;
class Program
{
public static void main()
{
double basic, da, hra, pf, gross, net_pay;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the basic salary: ");
basic=sc.nextDouble();
da=30/100.0*basic;
hra=12.5/100.0*basic;
pf=10/100.0*basic;
gross=basic+da+hra;
net_pay=gross-pf;
System.out.println("Gross salary: "+gross);
System.out.println("Net salary: "+net_pay);
}
}