I'm trying to write a payroll program that simply receives input, does some calculations and displays the output for EACH employee.
I have two types of employees, hourly and salary. I created a class for each type that extends to an abstract employee class:
public abstract class Employee{
private String name;
private String type;
private int hours;
private double rate;
}
public class SalaryEmployee extends Employee{
public SalaryEmployee(String type, String name, int hours, double rate){
this.type = type;
this.name = name;
this.hours = hours;
this.rate = rate;
}
public void print(){
}
}
In my main method, when I try to create my objects using the code below:
Employee employee;
if(type.equals("hourly"))
{
employee = new HourlyEmployee(type, name, hours, rate);
}
else
{
employee = new SalaryEmployee(type, name, hours, rate);
}
I get the following error when I try to compile:
Lab3.java:53: not a statement
SalaryEmployee employee = new SalaryEmployee(type, name, hours, rate);
^
Lab3.java:53: ';' expected
SalaryEmployee employee = new SalaryEmployee(type, name, hours, rate);
^
2 errors
Any idea what is happening here? I've looked around for messing semi colons or braces, but haven't found anything yet.
Thanks for looking.
SalaryEmployee employee = new SalaryEmployee(type, name, hours, rate);can't find in given code segment