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

Write a program that includes a method called pay , and accepts two parameters:

ID: 644748 • Letter: W

Question

Write a program that includes a method called pay, and accepts two parameters: a real number for an employees hourly wage and an integer for the number of hours the employee worked that day. The method should return how much money to pay the employee for this day. Example: the call pay ( 5.50, 6) should return 33.0

The employee should recieve "overtime" pay of 1.5 times the normal wage for any hours over 8. Example the call pay( 4.00 * 8 ) + ( 6.00 * 3 ). Include in the main method of this program Four Calls to the pay method. Two Calls for each one using the example data given above and Two Calls using the data you determine.

Explanation / Answer

import java.util.Scanner;
public class HelloWorld{
public static double Pay(double hours, double rate){
double salaryPay;
if(hours<=8){
salaryPay = hours*rate;
}
else{
int overtime = hours-8;
hours=hours-overtime;
salaryPay = (hours*rate)+(overtime*rate*1.5)
}
return salaryPay;

}
public static void main(String []args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter hourly rate");
double hourlyRate = sc.nextInt();
System.out.println("Enter hours you worked");
double hours = sc.nextInt();
double pay=0;
double salary = Pay(hours,hourlyRate);
System.out.println("Total salary to be paid is:-----> "+salary);
}
}

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