Question

In: Computer Science

Summary In this lab, you complete a prewritten Java program that calculates an employee’s productivity bonus...

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

  1. Ensure the file named EmployeeBonus.java is open.

  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. 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
  5. Your output should be:
    Employee Name: Kim Smith  
    Employee Bonus: $50.0
              
    
  6. // 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);
       }
    }   

Solutions

Expert Solution

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


Related Solutions

Understanding if-elseStatements Summary In this lab, you will complete a prewritten Java program that computes the...
Understanding if-elseStatements Summary In this lab, you will complete a prewritten Java program that computes the largest and smallest of three integer values. The three values are –50, 53, and 78. Instructions Two variables named largest and smallest are declared for you. Use these variables to store the largest and smallest of the three integer values. You must decide what other variables you will need and initialize them if appropriate. Write the rest of the program using assignment statements, if...
Summary In this lab, you complete a prewritten Python program that computes the largest and smallest...
Summary In this lab, you complete a prewritten Python program that computes the largest and smallest of three integer values. The three values are -50, 53, 78. Instructions Two variables named largestand smallest are assigned for you. Use these variables to store the largest and smallest of the three integer values. You must decide what other variables you will need and initialize them if appropriate. Write the rest of the program using assignment statements, if statements, or elifstatements as appropriate....
Summary In this lab, you use a counter-controlled while loop in a Java program provided for...
Summary In this lab, you use a counter-controlled while loop in a Java program provided for you. When completed, the program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. The data file contains the necessary variable declarations and some output statements. Instructions Ensure the file named Multiply.java is open. Write a counter-controlled while loop that uses the loop control variable to take on the values 0 through 10. Remember to initialize...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for the check amount, then ask the user what type of tipp they would like to leave: the choices are 1 for good tip (20%), 2 for an average tip (15%), or 3 for poor tip (10%). Use their input and an if-else to calculate the tip amount. Then calculate and output the final bill: check+tip print out the bill, exactly as shown (print the...
Summary In this lab, you will make additions to a C++ program that is provided. The...
Summary In this lab, you will make additions to a C++ program that is provided. The program is a guessing game. A random number between 1 and 10 is generated in the program. The user enters a number between 1 and 10, trying to guess the correct number. If the user guesses correctly, the program congratulates the user, and then the loop that controls guessing numbers exits; otherwise, the program asks the user if he or she wants to guess...
In java. Prefer Bluej Create a program in java that calculates area and perimeter of a...
In java. Prefer Bluej Create a program in java that calculates area and perimeter of a square - use a class and test program to calculate the area and perimeter; assume length of square is 7 ft.
Summary In this lab, you add the input and output statements to a partially completed Java...
Summary In this lab, you add the input and output statements to a partially completed Java program. When completed, the user should be able to enter a year, a month, and a day to determine if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31. Instructions Notice that variables have been declared for you. Write the simulated housekeeping() method...
Searching an Array for an Exact Match in Java Summary In this lab, you use what...
Searching an Array for an Exact Match in Java Summary In this lab, you use what you have learned about searching an array to find an exact match to complete a partially prewritten Java program. The program uses an array that contains valid names for 10 cities in Michigan. You ask the user of the program to enter a city name; your program then searches the array for that city name. If it is not found, the program should print...
Write a program in java which calculates the total price of an item you purchased which...
Write a program in java which calculates the total price of an item you purchased which includes sales tax. Create a Scanner object to read information from keyboard, Display prompts and get input, perform the calculation and display the Result of the program.
Create a program in java that calculates area and perimeter of a square - use a...
Create a program in java that calculates area and perimeter of a square - use a class and test program to calculate the area and perimeter; assume length of square is 7 ft.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT