Ok, I looked through a lot of forums in this website and I cannot find my problem. I keep getting an error stating “cannot find symbol” and points to the “n” in “new” on my EmployeeTest app. Here is my code:
first file:
import java.util.Scanner;
public class Employee
{
private String fName;
private String lName;
private Double mSalary;
public Employee( String first, String last, Double mth)
{
fName = first;
lName = last;
if ( mth > 0.00 )
mSalary = mth;
if ( mth < 0.00 )
mSalary = 0.00;
}
public void setFName( String first )
{
fName = first;
}
public void setLName( String last )
{
lName = last;
}
public void setMSalary( Double mth )
{
mSalary = mth;
}
public String getFName()
{
return fName;
}
public String getLName()
{
return lName;
}
public Double getMSalary()
{
return mSalary;
}
public void displayMessage()
{
System.out.printf( "%s %s has a monthly salary of $%.2f\n",
getFName(),
getLName(),
getMSalary() );
}
}
Second file:
public class EmployeeTest
{
public static void main( String[] args )
{
Employee myEmployee = new Employee(
"Fred", "Rogers", "10" );
System.out.printf( "Employee's first name is: %s\n",
myEmployee.getFName() );
System.out.printf( "\nEmployee's last name is: %s\n",
myEmployee.getLName() );
System.out.printf( "\nEmployee's monthly salary is: %d\n",
myEmployee.getMSalary() );
}
}
I have a feeling it has to do with my constructor but I cannot find out what the problem is! I must have looked over my code a ka-jillion times!
changing
EmployeeTestto:
and:
to: