尝试运行此代码时,我收到“找不到符号”错误。这是关于 List 代码行的。它把它扔在 List 和 ArrayList 上。我无法弄清楚这是如何错误地实施的。该脚本调用一个名为 Employee 的类。该列表将包含从 Employee 创建的所有对象。然后应该可以打印列表了。
import java.util.Scanner;
class PayrollProgram
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
List<Employee> employees = new ArrayList<>();
while (!emp.name.equals("STOP"))
{
Employee emp = new Employee();
System.out.print("Employee's Name: ");
emp.name = scan.next();
if(emp.name.equals("STOP"))
{
System.out.printf("The Application is STOPPING......");
break;
}
System.out.print("Enter hourly wage: $ ");
emp.wage = scan.nextDouble();
while (emp.wage < 0)
{
System.out.printf("Please Enter a Positive Number! \n");
System.out.print("Enter hourly wage: $ ");
emp.wage = scan.nextDouble();
}
System.out.print("Hours Worked in Week: ");
emp.hours = scan.nextDouble();
while (emp.hours < 0)
{
System.out.printf("Please Enter a Positive Number! \n");
System.out.print("Hours Worked in Week: ");
emp.hours = scan.nextDouble();
}
employees.add(emp);
emp.printEmployee();
}
for(Employee emp : employees)
{
System.out.println(emp.name);
}
}
}