I have a Java assignment due tonight, and I wrote this, but it will not compile. Can someone help me see what I'm doing wrong? Thanks!
My assignment is:
"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. "
Here is what I wrote:
import java.util.Scanner;
import java.text.NumberFormat;
public class payroll
{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
NumberFormat moneyFormat=NumberFormat.getCurrencyInstance();
String last_name; //employee last name
String first_name; //employee first name
float rate; //rate of pay
float hours; //hours worked
float total; //hours multiplied by rate of pay
System.out.print("Enter employee's last name: ");
last_name=input.next(); //input string
System.out.print("Enter employee's first name: ");
first_name=input.next(); //input string
System.out.print("Enter employee's hourly rate of pay: $");
rate=input.nextFloat(); //input real number
System.out.print("Enter number of hours worked: ");
hours=input.nextFloat(); //input real number
total=rate*hours; //total weekly pay
System.out.printf("The weekly pay for %s", first_name); //display first name
System.out.printf(" %s", last_name); //display last name
System.out.printf(" is %s", moneyFormat.format(total));// display total
}
//end method main
} //end class Payroll