1. Modify the Payroll Program application so it continues to request employee information until the user enters stop as the employee name.
2. 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.
2007-11-14
06:24:55
·
2 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design
here is my code...
import java.text.NumberFormat;
import java.util.Scanner;
import java.util.Locale;
public class PayrollProgram {
public static void main(String[] args)
{
Scanner input = new Scanner( System.in );
NumberFormat usFormat = NumberFormat.getCurrencyInstance();
String fName;
String lName;
double hourlyRate = 0.0;
int hours = 0;
System.out.println("Enter the following info for the employee: ");
System.out.println("First name: ");fName = input.next();
System.out.println("Last name: ");lName = input.next();
System.out.println("Hourly rate: ");hourlyRate = Double.parseDouble(input.next());
System.out.println("Hours worked this week: ");hours = Integer.parseInt(input.next());
System.out.println("Here is the employee's info: ");
System.out.println("Name: " + fName + " " + lName);
System.out.println("Weekly Pay: " + usFormat.format(hourlyRate * hours));
}
}
2007-11-14
06:28:02 ·
update #1
can anyone modify it for me?
please!!!
2007-11-14
06:38:21 ·
update #2