Question: Reforming the code to be four functions for computing performanceBonus, totalSala 1 y , taxDeduction, netSalary respectively. The main function is used as an interface

Reforming the code to be four functions for computing performanceBonus, totalSala1y, taxDeduction, netSalary respectively. The main function is used as an interface for entering employee information and displaying the results. (4 Marks)
public class EmployeeSalary {
public static void main(String[] args){ Scanner scanner = new Scanner(System.in); double CL, TA,MA; ;c,_..=--- System.out.print("Enter the basic pay: "); double basicPay = scanner.nextDouble();
System.out.print("Enter the performance rating (Excellent, Very Good, Good, Satisfactory): "); String performanceRating = scanner.next();
System.out.print("Enter the number of years of experience: "); int yearsOfExperience = scanner.nextlnt();
double performanceBonus =0; switch (performanceRating){
case "Excellent":performanceBonus = basicPay *0.1;break; case "Very Good": performanceBonus = basicPay *0.8;break; case "Good":performanceBonus = basicPay *0.5;break; default: break;}
if (basicPay *0.12>=2000){
ifbasicPay *0.12<=5000) CL= basicPay *0.12;
if (basicPay *0.12<2000) CL=2000; }
else CL=5000;
if (basicPay *0.07>=400){TA= basicPay; 0.07;
}else TA=400;
if (basicPay *0.08<=2500){ MA= basicPay *0.08; } else MA =2500;
double totalSalary = basicPay + performanceBonus + CL + TA + MA;
double taxDeduction=0;
if(totalSalary >10000) taxDeduction = totalSalary *0.1; else taxDeduction = totalSalary;
double= totalSalary *0.12;
double netSalary = totalSalary - taxDeduction - P ; System.out.println("Total Salary: $"+ totalSalary); System.out.println("Tax Deduction: $"+ taxDeduction); System.out.println("Net Salary: $"+ netSalary);
}}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!