In: Computer Science
Summary
In this lab, you complete a prewritten Java program that calculates an employee’s productivity bonus and prints the employee’s name and bonus. Bonuses are calculated based on an employee’s productivity score as shown below. A productivity score is calculated by first dividing an employee’s transactions dollar value by the number of transactions and then dividing the result by the number of shifts worked.
Productivity Score | Bonus |
---|---|
<=30 | $50 |
31–69 | $75 |
70–199 | $100 |
>= 200 | $200 |
Instructions
Ensure the file named EmployeeBonus.java is open.
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.
Design the logic, and write the rest of the program using a nested if statement.
Execute the program by clicking Run and enter the following as input:
Employee’s first name: Kim Smith Number of shifts: 25 Number of transactions: 75 Transaction dollar value: 40000.00
Employee Name: Kim Smith Employee Bonus: $50.0
// EmployeeBonus.java - This program calculates an employee's productivity bonus.
import java.util.Scanner;
public class EmployeeBonus
{
public static void main(String args[])
{
Scanner s = new
Scanner(System.in);
// Declare and initialize variables
here.
String employeeName;
double numTransactions;
String transactString;
double numShifts;
String shiftString;
double dollarValue;
String dollarString;
double score;
double bonus;
final double BONUS_1 = 50.00;
final double BONUS_2 = 75.00;
final double BONUS_3 =
100.00;
final double BONUS_4 =
200.00;
// This is the work done in the
housekeeping() method
System.out.println("Enter employee's name: ");
employeeName = s.nextLine();
System.out.println("Enter number of
shifts: ");
shiftString = s.nextLine();
System.out.println("Enter number of
transactions: ");
transactString =
s.nextLine();
System.out.println("Enter
transactions dollar value: ");
dollarString = s.nextLine();
numShifts =
Double.parseDouble(shiftString);
numTransactions =
Double.parseDouble(transactString);
dollarValue =
Double.parseDouble(dollarString);
// This is the work done in the
detailLoop() method
// Write your code here
// This is the work done in the
endOfJob() method
// Output.
System.out.println("Employee Name:
" + employeeName);
System.out.println("Employee Bonus:
$" + bonus);
System.exit(0);
}
}
// EmployeeBonus.java - This program calculates an employee's productivity bonus. import java.util.Scanner; public class EmployeeBonus { public static void main(String args[]) { Scanner s = new Scanner(System.in); // Declare and initialize variables here. String employeeName; double numTransactions; String transactString; double numShifts; String shiftString; double dollarValue; String dollarString; double score; double bonus; final double BONUS_1 = 50.00; final double BONUS_2 = 75.00; final double BONUS_3 = 100.00; final double BONUS_4 = 200.00; // This is the work done in the housekeeping() method System.out.print("Enter employee's name: "); employeeName = s.nextLine(); System.out.print("Enter number of shifts: "); shiftString = s.nextLine(); System.out.print("Enter number of transactions: "); transactString = s.nextLine(); System.out.print("Enter transactions dollar value: "); dollarString = s.nextLine(); numShifts = Double.parseDouble(shiftString); numTransactions = Double.parseDouble(transactString); dollarValue = Double.parseDouble(dollarString); // This is the work done in the detailLoop() method // Write your code here score = (dollarValue / numTransactions)/numShifts; if(score <= 30){ bonus = 50; } else if(score < 70){ bonus = 75; } else if(score < 200){ bonus = 100; } else{ bonus = 200; } // This is the work done in the endOfJob() method // Output. System.out.println("Employee Name: " + employeeName); System.out.println("Employee Bonus: $" + bonus); System.exit(0); } }