Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are working for a FOO software development company as an hourly paid employe

ID: 3924227 • Letter: Y

Question

You are working for a FOO software development company as an hourly paid employee. In FOO, all hourly paid employees are required to work at least 15 hours but no more than 60 hours per week. Your weekly gross pay is calculated by multiplying the number of hours you worked in a week with your pay rate. However, if you work overtime (i.e. more than 40 hours in a week), the overtime pay rate is 1.5 times of normal rate. For example, if your pay rate is $20 per hour and you worked 45 hours this week, your gross pay for this week will be $20*40+$20*1.5*5=$950. Only whole hours are counted and entered (i.e. hours will be an integer.) If you work less than 15 hours this week your pay will be deferred to next week and you get $0 paid this week. If you work more than 60 hours this week you only be paid for 60 hours and the remaining hours will be forfeited.

Write a Java program that reads in the number of hours you worked this week, your hourly pay rate and then calculates and outputs the gross pay. The program should output appropriate message (e.g. hours deferred, overtime ignored, …) in addition to gross output. Test your program with the following data:

Hours worked

Hourly pay rate

35

$25.0

22

$18.5

42

$20

58

$22.8

12

$25

65

$25

Sample input/output test runs may look like: (user input shown in bold).

Please enter hours you worked this week: 42

Please enter your hourly pay rate: 20

Your gross pay is $860.

Please enter hours you worked this week: 10

Please enter your hourly pay rate: 20

Your gross pay is $0.

Sorry you need to work at least 15 hours to get paid this week.

Your hours worked will be deferred to next week.

Hours worked

Hourly pay rate

35

$25.0

22

$18.5

42

$20

58

$22.8

12

$25

65

$25

Explanation / Answer

Hi, Please find my code:

import java.util.Scanner;

public class EmployeePayroll {

public static void main(String[] args) {

      

       // creating scanner object to take user input

       Scanner sc = new Scanner(System.in);

      

       // declaring variables

       int hoursWorked;

       double hoursRate;

      

       // taking user input

       System.out.print("Please enter hours you worked this week: ");

       hoursWorked = sc.nextInt();

      

       System.out.print("Please enter your hourly pay rate: ");

       hoursRate = sc.nextDouble();

      

       // calculating gross pay

       double grossPay = 0;

       if(hoursWorked < 15){

           grossPay = 0;

       }

       else if(hoursWorked > 40){

           grossPay = hoursRate*40 + (hoursWorked-40)*1.5*hoursRate;

       }else{

           grossPay = hoursRate*hoursWorked;

       }

       // Output

       System.out.println("Your gross pay is $"+grossPay);

       if(hoursWorked < 15){

          

           System.out.println("Sorry you need to work at least 15 hours to get paid this week "+

                               "Your hours worked will be deferred to next week.");

       }

   }

}

/*

Sample Run:

Please enter hours you worked this week: 56

Please enter your hourly pay rate: 34

Your gross pay is $2176.0

Please enter hours you worked this week: 13

Please enter your hourly pay rate: 22.8

Your gross pay is $0.0

Sorry you need to work at least 15 hours to get paid this week

Your hours worked will be deferred to next week.

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote