好的,我浏览了这个网站上的很多论坛,我找不到我的问题。我不断收到一条错误消息,指出“找不到符号”,并在我的 EmployeeTest 应用程序上指向“新”中的“n”。这是我的代码:
第一个文件:
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() );
}
}
第二个文件:
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() );
}
}
我感觉它与我的构造函数有关,但我无法找出问题所在!我一定已经检查了我的代码 ka-jillion 倍!