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

Write a public method that takes two arguments: a double representing the number

ID: 3919332 • Letter: W

Question

Write a public method that takes two arguments: a double representing the number of hours worked and a double representing the hourly pay, and returns a double representing the weekly pay. If the hours are less than or equal to 40, the weekly pay should be hours times hourly pay. If the hours are greater than 40 and less than 80, the weekly pay should be 40 times the hourly pay, plus the hours in excess of 40 times hourly pay times 1.5. If the hours worked are entered as less than zero or greater than 80, print an error message saying "incorrect number of hours entered" and return 0.0;

Explanation / Answer

public double weeklyPay(double hoursWorked ,double hourlyPay)
   {
       if(hoursWorked <= 40)
           return hoursWorked*hourlyPay;
       else if(hoursWorked >= 40 && hoursWorked <80)
           return 40*hourlyPay+ (hoursWorked-40)*1.5*hourlyPay;
       else
       {
           System.out.println("incorrect number of hours entered");
       }
       return 0.0;
   }

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