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

•For this classwork, use JOptionPane (not Scanner) •Write a method called calcWa

ID: 3701911 • Letter: #

Question

•For this classwork, use JOptionPane (not Scanner)

•Write a method called calcWage which takes two parameters:

•Hours worked

•Hourly Rate

calcWage will return the amount needed to be paid, by multiplying the hours worked by the hourly rate.

•Write a main method that asks the user for the number of hours they worked on 3 different days and their daily rate. Call calcWage to calculate the total wage. Use String.format to format the output. Use a LOOP!

•Add documentation comments to your methods and generate the Javadoc. Attach a screenshot of the Javadoc for your method.

Code in JAVA

Explanation / Answer

Below is your code: -

public class EmployeePay {

/**

*

* method to calculate the wage of hourly employee

*

*

*

* @param hours

* double hours, rate in double

*

* @return wage in double

*

*/

public static double calcWage(double hours, double rate) {

// return the wage by multiplying the hours and rate

return hours * rate;

}

/**

*

* Main method to run the code

*

*

*

* @param args[]

* - command line arguments

*

*/

public static void main(String[] args) {

// Declare variables for hours and rate

double hours;

double rate;

// Variable for output

String output;

double totalWage = 0.0;

// loop to get the inputs using JoptionPane for 3 different days

for (int i = 1; i <= 3; i++) {

// Getting hours for each day

hours = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter the hours worked on Day #" + i));

// Getting rate for each day

rate = Double.parseDouble(JOptionPane.showInputDialog(null, "Please enter the hourly rate for Day #" + i));

totalWage = totalWage + calcWage(hours, rate);

}

// Formatting the output using String.format

output = String.format("Total wage is: %f", totalWage);

// Displaying wage for three days

JOptionPane.showMessageDialog(null, output);

}

}