89.6k views
3 votes
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
Your output should be:
Employee Name: Kim Smith
Employee Bonus: $50.0

EmployeeBonus.java code:
// 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);

User Tilo
by
8.1k points

1 Answer

5 votes

Answer:

import java.util.Scanner;

public class EmployeeBonus {

public static void main(String args[]) {

Scanner s = new Scanner(System.in);

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;

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);

score = numTransactions / numShifts;

if (score <= 30) {

bonus = BONUS_1;

} else if (score >= 31 && score <= 69) {

bonus = BONUS_2;

} else if (score >= 70 && score <= 199) {

bonus = BONUS_3;

} else {

bonus = BONUS_4;

}

System.out.println("Employee Name: " + employeeName);

System.out.println("Employee Bonus: $" + bonus);

}

}

User Irperez
by
8.8k points