complete a prewritten Java program that calculates an employee’s end-of-year bonus and prints the employee’s

complete a prewritten Java program that calculates an employee’s end-of-year bonus and prints the employee’s name, yearly salary, performance rating, and bonus. In this program, bonuses are calculated based on an employee’s annual salary and their performance rating. Below, Table 4-5 shows the employee ratings and bonuses:

Rating Bonus
1 25% of annual salary
2 15% of annual salary
3 10% of annual salary
4 None
Table 4-5

Instructions

Variables have been declared , and the input statements and output statements have been written. Read them over carefully before proceeding to the next step.
Design the logic and write the rest of the program using a switch statement.
Execute the program entering the following as input:

Confirm that your output matches the following:
Employee Name: Jeanne Hanson
Employee Salary: $70000.0
Employee Rating: 2
Employee Bonus: $10500.0
Employee’s name: Jeanne Hanson
Employee’s salary: 70000.00
Employee’s performance rating: 2

arly bonus.

import java.util.Scanner;

public class EmployeeBonus2

{

public static void main(String args[])

{

// Declare and initialize variables.

String employeeName;

String salaryString;

double employeeSalary;

String ratingString;

int employeeRating;

double employeeBonus;

final double BONUS_1 = .25;

final double BONUS_2 = .15;

final double BONUS_3 = .10;

final double NO_BONUS = 0.00;

final int RATING_1 = 1;

final int RATING_2 = 2;

final int RATING_3 = 3;

// This is the work done in the housekeeping() method

// Get user input.

Scanner input = new Scanner(System.in);

System.out.print(“Enter employee’s name: “);

employeeName = input.nextLine();

System.out.print(“Enter employee’s yearly salary: “);

salaryString = input.nextLine();

System.out.print(“Enter employee’s performance rating: “);

ratingString = input.nextLine();

// Convert Strings to int or double.

employeeSalary = Double.parseDouble(salaryString);

employeeRating = Integer.parseInt(ratingString);

// This is the work done in the detailLoop() method

// Use switch statement here to calculate bonus based on rating.

final int RATING_4 = 4;

//Switch – case begin

switch(employeeRating){

case RATING_1:

//Calculates bonus 25% of salary

employeeBonus = employeeSalary * (BONUS_1);

break;

case RATING_2:

//Calculates bonus 15% of salary

employeeBonus = employeeSalary * (BONUS_2);

break;

case RATING_3:

//Calculates bonus 10% of salary

employeeBonus = employeeSalary * (BONUS_3);

break;

case RATING_4:

//No bonus

employeeBonus = NO_BONUS;

break;

default:

System.out.println(“ERROR: Performance Rating must between 1 – 4 inclusive “);

// This is the work done in the endOfJob() method

// Output.

System.out.println(“Employee Name ” + employeeName);

System.out.println(“Employee Salary $” + employeeSalary);

System.out.println(“Employee Rating ” + employeeRating);

System.out.println(“Employee Bonus $” + employeeBonus);

System.exit(0);

}

}

}

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?