Ok, I am getting 2 errors on line 65 it says class or interface expected and again on line 65 saying { expected. The assignment is to 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 that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate. Make sure the program maintains all the functionality required in previous assignments and your source code is readable and well documented.
This is what I have so far and cannot figure out how to fix the errors.
// WeeklyPay2.java
import java.io.*;
import java.text.*;
public class WeeklyPay2
{
public static void main (String[] args)throws Exception
{
DataInput keyboard = new DataInputStream(System.in);
DecimalFormat currency = new DecimalFormat("$ 0.00");
String temp;
char response;
// Variable declaration
String employee_name;
float wage_rate, hours_worked;
while (true)
{
// User Input
System.out.print("Please enter the employee's name: ");
employee_name = keyboard.readLine();
if (employee_name.equalsIgnoreCase("stop"))
break;
System.out.print("Wage rate ($/hour): ");
temp = keyboard.readLine();
wage_rate = Float.valueOf(temp).floatValue();
while (wage_rate < 0)
{
System.out.print("Invalid input. Please enter a positive value: ");
temp = keyboard.readLine();
wage_rate = Float.valueOf(temp).floatValue();
}
System.out.print("Hours worked per week: ");
temp = keyboard.readLine();
hours_worked = Float.valueOf(temp).floatValue();
while (hours_worked < 0)
{
System.out.print("Invalid input. Please enter a positive value: ");
temp = keyboard.readLine();
hours_worked = Float.valueOf(temp).floatValue();
}
// Output
System.out.println("");
System.out.println(employee_name + "'s weekly pay is " + currency.format(wage_rate * hours_worked) + "\n\n\n");
}
System.out.print("\n\nHit 'Enter' to end...");
response = (char)System.in.read();
}
}
//Employee.java
{public class Employee.java
{
// VARIABLES
private String name;
private float wage_rate, hours_worked;
// CONSTRUCTOR METHOD
public Employee(String name, float wage_rate, float hours_worked)
{this.name = name;
this.wage_rate = wage_rate;
this.hours_worked = hours_worked;
}
public float getWeeklyPay()
{
return wage_rate * hours_worked;
}
public String getName()
{
return name;
}
} }