Modify the payroll program application


Discuss the below:

Q: Modify the Payroll Program application so it continues to request employee information until the user enters stop as the employee name. In addition, program the application to check that the hourly rate and number of hours worked are positive numbers. If either the hourly rate or the number of hours worked is not a positive value, the application should
prompt the user to enter a positive amount.

The teacher posted that this is what the program should have looked like:
import java.util.Scanner;

public class Payroll
{
public static void main (String args[])
{

String name;
double payRate;
double hours;
double weeklyPay;

Scanner input = new Scanner(System.in);

System.out.print("Enter name: ");
name = input.next();

System.out.print("Enter payrate: "); // prompt
payRate = input.nextDouble();

System.out.print("Enter hours: "); // prompt
hours = input.nextDouble();

weeklyPay = payRate * hours;

System.out.print(name + " earned ");
System.out.printf("$ %.2fn", weeklyPay);

} //end of main method

} // end of Payroll class

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Modify the payroll program application
Reference No:- TGS01935128

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)