Lab exercise Complete the following exercisesin yourlab sess
Solution
Java code:
import java.util.Scanner;
public class salary
{
public static void main(String[] args)
{
double current_salary;
int rating;
Scanner scanner = new Scanner(System.in);
System.out.println(\"Enter current salary: \");
current_salary = scanner.nextFloat();
System.out.println(\"Enter rating: \");
rating = scanner.nextInt();
if(rating == 1)
{
System.out.println(\"The Amount raise in the salary is : \" + (current_salary*0.06 ));
System.out.println(\"The Total Amount of new salary is : \" + ((current_salary*0.06 ) + current_salary));
}
else if (rating == 2)
{
System.out.println(\"The Amount raise in the salary is : \" + (current_salary*0.04 ));
System.out.println(\"The Total Amount of new salary is : \" + ((current_salary*0.04 ) + current_salary));
}
else
{
System.out.println(\"The Amount raise in the salary is : \" + (current_salary*0.015 ));
System.out.println(\"The Total Amount of new salary is : \" + ((current_salary*0.015 ) + current_salary));
}
}
}
Sample Output:
Enter currenr salary:
100
Enter rating:
1
The Amount raise in the salary is : 6.0
The Total Amount of new salary is : 106.0
Enter currenr salary:
100
Enter rating:
2
The Amount raise in the salary is : 4.0
The Total Amount of new salary is : 104.0
Enter currenr salary:
100
Enter rating:
3
The Amount raise in the salary is : 1.5
The Total Amount of new salary is : 101.5

