Using a switch Statement Summary In this lab, you 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: D Table 4-5 & Instructions ℗ Rating Bonus 1 2 3 Grading 4 25% of annual salary 15% of annual salary 10% of annual salary None 1. Variables have been declared for you, and the input statements and output statements have been written. Read them over carefully before you proceed to the next step. 2. Design the logic and write the rest of the program using a switch statement. 3. Execute the program entering the following as input: Employee's name: Jeanne Hanson Employee's salary: 70000.00 Employee's performance rating: 2 4. Confirm that your output matches the following: Employee Name: Jeanne Hanson Employee Salary: $70000.0 Employee Rating: 2 Employee Bonus: $10500.0 horam click the Submit button to record your EmployeeBonus2.java + 1 // EmployeeBonus2.java - This program calculates an employee's yearly bonus. 2 3 import java.util.Scanner; 4 5 public class EmployeeBonus2 6 { 7 8 9 10 11 12 13 14 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 } 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 = final double BONUS_2 = 25; 15; 10; final double NO BONUS = 0.00; final double BONUS_3 = final int RATING 1 = 1; final int RATING 22; 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: "); System.out.print("Enter employee's performance rating: "); salaryString input.nextLine(); ratingString input.nextLine(); // Convert Strings to int or double. Double.parseDouble(salaryString); employeeSalary employeeRating = Integer.parseInt(ratingString); // This is the work done in the detailLoop() method // Use switch statement here to calculate bonus based on rating. // This is the work done in the endOf Job() 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);
Using a switch Statement Summary In this lab, you 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: D Table 4-5 & Instructions ℗ Rating Bonus 1 2 3 Grading 4 25% of annual salary 15% of annual salary 10% of annual salary None 1. Variables have been declared for you, and the input statements and output statements have been written. Read them over carefully before you proceed to the next step. 2. Design the logic and write the rest of the program using a switch statement. 3. Execute the program entering the following as input: Employee's name: Jeanne Hanson Employee's salary: 70000.00 Employee's performance rating: 2 4. Confirm that your output matches the following: Employee Name: Jeanne Hanson Employee Salary: $70000.0 Employee Rating: 2 Employee Bonus: $10500.0 horam click the Submit button to record your EmployeeBonus2.java + 1 // EmployeeBonus2.java - This program calculates an employee's yearly bonus. 2 3 import java.util.Scanner; 4 5 public class EmployeeBonus2 6 { 7 8 9 10 11 12 13 14 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 } 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 = final double BONUS_2 = 25; 15; 10; final double NO BONUS = 0.00; final double BONUS_3 = final int RATING 1 = 1; final int RATING 22; 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: "); System.out.print("Enter employee's performance rating: "); salaryString input.nextLine(); ratingString input.nextLine(); // Convert Strings to int or double. Double.parseDouble(salaryString); employeeSalary employeeRating = Integer.parseInt(ratingString); // This is the work done in the detailLoop() method // Use switch statement here to calculate bonus based on rating. // This is the work done in the endOf Job() 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);
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education