Payroll Program Assistance
I need help with my payroll program which is for my Java class. The assignment is: Modify the payroll program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within the class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate.
With the program that I have below, I'm getting <indentier> expected
weeklyPay.calculatePay( rate, hours );
Help is needed as soon as possible because it is due today.
import java.util.Scanner;
public class Payroll3
{
Employee weeklyPay = new Employee();
weeklyPay.calculatePay( rate, hours );
}
class Employee
{
double rate;
double hours;
double pay;
private String employeeName;
public Employee( String name )
{
employeeName = name;
}
public void setEmployeeName( String name )
{
employeeName = name;
}
public String getEmployeeName()
{
return employeeName;
}
public static double calculatePay( double rate, double hours )
{
Scanner input = new Scanner( System.in );
System.out.print( "Enter employee name or stop to quit: " );
employeeName = input.nextLine();
while ( !employeeName.equals("stop") )
{
System.out.printf( "Enter %s's hourly rate: ", employeeName );
rate = input.nextDouble();
System.out.printf( "Enter %s's number of hours worked: ", employeeName );
hours = input.nextDouble();
pay = rate*hours;
System.out.printf( "%s's payment for the week is $%.2f\n", employeeName, pay );
System.out.println();
System.out.print( "Enter employee name or stop to quit: " );
employeeName = input.next();
System.out.println();
}
}
}

