I am having problems with the following code. Can anyone help?
//CheckPoint: Payroll Program Part 3
//Payroll3.java
//Payroll program that calculates the weekly pay for an employee.
import java.util.Scanner; // program uses class Scanner
public class Payroll3
{
// main method begins execution of java application
public static void main( String args[] )
{
private string name;
private float rate;
private float hours;
// Constructor to store Employee Data
public void Payroll3( string nameOfEmployee, float hourlyRate, float hoursWorked )
{
name = nameOfEmployee;
rate = hourlyRate;
hours = hoursWorked;
} // end constructor
} //end class EmployeeData
System.out.println( "Welcome to the Payroll Program! " );
boolean quit = false; // This flag will control whether we exit the loop below
// Loop until user types "quit" as the employee name:
while (!quit)
{
// create scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
System.out.println(); // outputs a blank line
System.out.print( "Please enter the employee name or quit to terminate program: " );
// prompt for and input employee name
String nameOfEmployee = input.nextLine(); // read what user has inputted
if ( nameOfEmployee.equals("quit")) // Check whether user indicated to quit program
{
System.out.println( "Program has ended" );
quit = true;
}
else
{
// User did not indicate to stop, so continue reading info for this iteration:
float hourlyRate; // first number to multiply
float hoursWorked; // second number to multiply
float product; // product of hourlyRate and hoursWorked
System.out.print( "Enter hourly rate: " ); // prompt
hourlyRate = input.nextFloat(); // read first number from user
while (hourlyRate <= 0) // prompt until a positive value is entered
{
System.out.print( "Hourly rate must be a positive value. " +
"Please enter the hourly rate again: " ); // prompt for positive value for hourly rate
hourlyRate = input.nextFloat(); // read first number again
}
System.out.print( "Enter hours worked: " ); // prompt
hoursWorked = input.nextFloat(); // read second number from user
while (hoursWorked <= 0) // prompt until a positive value is entered
{
System.out.print( "Hours worked must be a positive value. " +
"Please enter the hours worked again: " ); // prompt for positive value for hours worked
hoursWorked = input.nextFloat(); // read second number again
}
product = (float) hourlyRate * hoursWorked; // multiply the hourly rate by the hours worked
// Display output for this iteration
System.out.println(); // outputs a blank line
System.out.print( nameOfEmployee ); // display employee name
System.out.printf( "'s weekly pay is: $%,.2f\n", product); // display product
System.out.println(); // outputs a blank line
}
}
// Display ending message:
System.out.println( "Thank you for using the Payroll program!" );
System.out.println(); // outputs a blank line
} // end method main
} // end class Payroll3
I have the following errors
Payroll3.java:25: 'class' or 'interface' expected
public static void main( String arg[] )
___________^
Payroll3.java:97: 'class' or 'interface' expected
} // end class Payroll3
^
Payroll3.java:97: 'class' or 'interface' expected
} //end class Payroll3
__________________^
Edited by: seanjohn07 on Dec 22, 2008 10:02 PM