The following program takes two numbers (pay rate & hours) andmultiplies them to
ID: 3615104 • Letter: T
Question
The following program takes two numbers (pay rate & hours) andmultiplies them to get grosspay. It then calculates net pay by subtracting 15% of thegross pay. Copy this code into your
compiler. Follow the code and the comments to understand howthe program works and fill in the
appropriate code so the program performs as it should.
public class Lab9_Ex1
{
public static void main(String [] args)
{
double payRate;
double grossPay;
double netPay;
int hours;
Scanner input = new Scanner(System.in);
System.out.println("Welcome to the Pay RollProgram");
printDescription(); //Call to Descriptionmethod
System.out.print("Please input the pay perhour: ");
payRate = input.nextDouble();
System.out.println(" Please input the number ofhours worked: “);
hours = input.nextInt();
System.out.println(“ ”);
grossPay = computePaycheck(payRate,hours);
netPay = computeNetPay(grossPay);
// Fill in the code to output grossPay andto calculate netPay
System.out.println("The net pay is $" +netPay);
System.out.println("We hope you enjoyed thisprogram");
System.exit(0);
}
// ********************************************************************
// printDescription
//
// task: This method prints aprogram description
// data in: none
// data out: none
//
// ********************************************************************
public static void printDescription() //The method heading
{
System.out.println("********************************************* ");System.out.println("This program takes two numbers (pay rate &“ +
“hours)");
System.out.println("and multiplies them to get gross pay");
System.out.println("itthen calculates net pay by subtracting 15%");
System.out.println("******************************************** ");
}
// *********************************************************************
// computePaycheck
//
// task: This method takes rateand time and multiples them to
// get gross pay.
// data in: pay rate and time in hours worked
// data out: the gross pay
//
// ********************************************************************
public static double computePaycheck(double rate, int time)
{
// Fill in the code to find grosspay
}
Explanation / Answer
please rate - thanks import java.util.*; public class untitled { public static void main(String [] args) { double payRate; double grossPay; double netPay; int hours; Scanner input = new Scanner(System.in); System.out.println("Welcome to the Pay RollProgram"); printDescription(); //Call to Descriptionmethod System.out.print("Please input the pay perhour: "); payRate = input.nextDouble(); System.out.println(" Please input the number ofhours worked: "); hours = input.nextInt(); System.out.println(" "); grossPay = computePaycheck(payRate,hours); netPay = computeNetPay(grossPay); // Fill in the code to output grossPay andto calculate netPay System.out.println("The gross pay is $" +grossPay); System.out.println("The net pay is $" +netPay); System.out.println("We hope you enjoyed thisprogram"); System.exit(0); } // ******************************************************************** // printDescription // // task: This method prints aprogram description // data in: none // data out: none // // ******************************************************************** public static void printDescription() //The method heading { System.out.println("********************************************* "); System.out.println("This program takes two numbers (pay rate &" +"hours)"); System.out.println("and multiplies them to get gross pay"); System.out.println("itthen calculates net pay by subtracting 15%"); System.out.println("******************************************** "); } // ********************************************************************* // computePaycheck // // task: This method takes rateand time and multiples them to // get gross pay. // data in: pay rate and time in hours worked // data out: the gross pay // // ******************************************************************** public static double computePaycheck(double rate, int time) { // Fill in the code to find grosspay double grosspay=rate*time; return grosspay; } public static double computeNetPay(double grossPay) {double netpay=grossPay-(.15*grossPay); return netpay; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.