2. Write a java program to accept salary and print bonus for the employee
Salary
bonus
Upto 10000
2%
More than 10000 upto 60000
4%
More than 60000 upto 80000
5%
More than 80000
6%
Answers
Answered by
4
Question:-
- Write a java program to accept salary and print bonus for the employee.
Program:-
import java.util.*;
class Bonus
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the salary: ");
double salary=sc.nextDouble();
double bonus=0;
if(salary<=10000)
bonus=2/100.0*salary;
else if(salary<=60000)
bonus=4/100.0*salary;
else if(salary<=80000)
bonus=5/100.0*salary;
else
bonus=6/100.0*salary;
System.out.println("Bonus: "+bonus);
salary+=bonus;
System.out.println("Total Salary: "+salary);
}
}
Similar questions