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

Write a program called Program1 with a main method that asks the user for his or

ID: 3759291 • Letter: W

Question

Write a program called Program1 with a main method that asks the user for his or her pay rate and the number of hours he or she worked this week. Then the main method should call the following two methods and store the results it gets from each method.

getTotalPay - takes two parameters, an integer for the number of hours worked and a double for the pay rate. If the number of hours is less than or equal to 40, it simply multiplies them together and returns the result. If the number of hours is greater than 40, he gets an additional dollar for each hour over 40 that he or she has worked. For example if the pay rate is $10 and someone worked 41 hours, they would get $411.00.

getPercentage - takes one parameter - the number of hours worked, and returns the time worked as a percentage of 40 hours. For example, if the number of hours worked is 20, it should return 50.0.

The main method also calls a third method which displays the results nicely on the screen. The third method, displayOutput, should have four parameters and should print the output as shown below (use printf).

Pay Rate: $10.0
Hours Worked: 41
Percentage worked per week: 102.5%

Total pay earned: $411.00

Explanation / Answer

Program1.java

/*
* CHEGG EXPERT ANSWER
*/

package com.student;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
*
* @AUTHOR VINOD
*/
class Totalrate
{
public void getTotalpay(int noofhoursworked,double payrate)
{
double totalpay=(noofhoursworked*payrate);
if(noofhoursworked<=40){
System.out.println("Total pay="+totalpay);
}
else
{

totalpay=totalpay+1;
System.out.println("Total pay="+totalpay);
}
}
public void getPercentage(int noofhoursworked)
{
int percentage= (noofhoursworked/40)*100;
System.out.println("percentage worked"+percentage);
}
}
public class Program1 {
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter no of hours worked");
int noofhoursworked=Integer.parseInt(br.readLine());
System.out.println("enter thr payrate");
double payrate=Double.parseDouble(br.readLine());
Totalrate t=new Totalrate();
t.getTotalpay(noofhoursworked, payrate);
t.getPercentage(noofhoursworked);


}

}

output javac Program1.java

java Program1

run:
enter no of hours worked
41
enter thr payrate
10
Total pay=411.0
percentage worked100
BUILD SUCCESSFUL (total time: 3 seconds)

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