6. Your output should be: Employee Name: Kim Smith :Employee Bonus: $ 50.00 You
ID: 3813483 • Letter: 6
Question
6. Your output should be: Employee Name: Kim Smith
:Employee Bonus: $ 50.00
You cannot control the number of places that appear after the decimal point until you learn more about Java in Chapter of this book.
Lab 4-3: Understanding Nested if Statemerto produ progra that are calculated based on an In this lab, you Java calcul and and prints the employee's name and productivity score is shown in Table 4-4. A transactions employee's dollar value by the number of an employee's of shifts worked. O dividing the result by the number Productivity Score Bonus $50 30 $75 31-69 $100 70-199 $200 200 Table 4-4 Employee productivity scores and bonuses 1. open the file named Employee Bonus.java using Notepad or the text editor of your choice 2. 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. 3. Design the logic and write the rest of the program using a nested if statement. 4. Compile the program. 5 Execute the program entering the following as input: Employee's name: Kim Smith Number of Shifts: 25 Number of transactions: 75 Transaction dollar value: 40000.00 maintain switch You includ swi to that andExplanation / Answer
The EmployeeBonus.java code is as below.
Since the code provided has not been given here, I have written the complete program.
CODE:
import java.util.Scanner;
public class EmployeeBonus {
public static void main(String[] args) {
// Scanner is required to read from the user input.
Scanner sc = new Scanner(System.in);
System.out.println("Please enter as per the below reqts.");
System.out.println("Employee's Name: ");
String empName = sc.nextLine();
System.out.println("Number of Shifts: ");
int numShifts = sc.nextInt();
System.out.println("Number of transactions: ");
int numTransactions = sc.nextInt();
System.out.println("Transaction dollar value: ");
double transValue = sc.nextDouble();
sc.close();
// calculate the productivityScore as given in the problem statement.
int productivityScore = (int) ((transValue/numTransactions)/numShifts);
double bonus = 0;
// Nested If used to calculate the bonus.
if(productivityScore <= 30)
bonus = 50;
else if (productivityScore > 30 && productivityScore < 70)
bonus = 75;
else if (productivityScore >= 70 && productivityScore < 200)
bonus = 100;
else if(productivityScore >= 200)
bonus = 200;
// print the output.
System.out.println("Employee Name: " + empName);
System.out.println("Employee Bonus: $" + bonus);
}
}
OUTPUT:
Please enter as per the below reqts.
Employee's Name:
Kim Smith
Number of Shifts:
25
Number of transactions:
75
Transaction dollar value:
40000.00
Employee Name: Kim Smith
Employee Bonus: $50.0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.