Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSCE 111

Programming Assignment 1

Fall 2022

1 Problem

Foo Corporation needs a program to calculate how much to pay their hourly employees. The US Depart ment of Labor requires that employees get paid 1.5 times for any hours over 40 that they work in a single week. For example, if an employee works 45 hours, they get 5 hours of overtime, at 1.5 times their base pay. The state of Massachusetts requires that hourly employees be paid at least $8.00 an hour. Foo Corporation requires that an employee not work more than 60 hours in a week.

2 Summary of Rules

 An employee gets paid (hours worked) × (base pay), for each hour up to 40 hours.

 For every hour over 40, they get overtime = (base pay) × 1.5.

 The base pay must not be less than the minimum wage ($8.00 an hour). If it is, print an error.  If the number of hours is greater than 60, print an error message.

Write a (static) method with name calculate” that takes (atleast) the base pay and hours worked as parameters, and prints the total pay or an error. Write a public static void main method that prompts the user to supply data for each employee and calls this method for each of these employees. When the employee  name  is quit” , the  program should exit without processing the employee. Here are some examples of the output. You don’t have to print the table header as shown below—you will print the name, the base pay, hours worked, and the outcome separated by space(example output is attached below).

Test case #      Name               Base Pay          Hours                                        Outcome

Test case 1: Jack Frost           $7.50                  35           Error! Base pay needs to be atleast $8.00.

Test case 2:  John Doe          $8.20                 47          Ok! Total weekly pay is $414. 10.

Test case 3: Dan Ackroyd      $10.00               73           Error! Cannot work more than 60 hours/week. At the prompt, a user should be able to supply the name, base pay, and hours of work in a single line. The format of the input is as follows.

Example input record for an employee

8.20 35 Jack Frost

The base pay is a double, the # of hours worked is an int, and the name could comprise of several strings for e.g., the name could be ( 1) FirstName LastName, (2) FirstName, MiddleName, LastName etc. Basically, after reading the  base  pay and  hours worked, the rest of the line will be the name of the employee.

3 Hint

Use the java.util.Scanner class as described in the JDK documentation and in your text book.

Do not try to write the entire program in one go. It is much easier to write a small piece and test it, then write another small piece and test it. For example, start by writing just a skeleton of your method and your main program. Then add the code to do the normal salary computation, without any special rules. Then add each additional rule, one at a time. You should test your program with simple test inputs to

check that you handle each case.

Heres an example output.

 

4 Submission

You will submit a Java file FooCorp.java that implements your program. We should be able to compile your program by running javac FooCorp.java to create a FooCorp.class file. We should be able to run your program with java FooCorp and provide data on the input.

Instructions on how to submit this file will be made available later. In order for us to run a Gradescope autograder on your program you must generate output in the exact format specified. If you believe that your output is in the correct format but the autograder rejects it, check with your TA.