我目前正在参加Java入门课程,我的导师要求我们制作一个程序。他为我们提供了3个IO类来输入netbeans来修复一些错误。该程序要求我们输入员工的信息并将该信息输出到文件中。当我这样做时,我找不到符号错误。我将Keyboard类放在userinputs文件夹中,并且工作正常。我遇到了OutputFile的问题。如果我没有将导入放在屏幕顶部,我会在主方法下的前两行出错。当我将导入放在程序的顶部时,如图所示,这两个错误消失,但后来我在代码的导入行上得到了错误。我再次入门级别,所以我底部的代码可能已关闭,但由于这些错误,我无法对其进行测试。任何帮助都会很棒,谢谢!
package practice;
import userinputs.Keyboard;
import javax.swing.JOptionPane;
import userinputs.OutputFile;
/**
*
* @author hitztp
*/
public class Practice
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
OutputFile payrollFile;
payrollFile = new OutputFile("payroll.txt");
Keyboard k;
k = new Keyboard();
String name, answer;
Double payrate, hours;
do
{
JOptionPane.showInputDialog("Please enter employee's full name.");
name = k.readString();
JOptionPane.showInputDialog("Please enter employee's payrate.");
payrate = k.readDouble();
JOptionPane.showInputDialog("Please enter employee's hours worked.");
hours = k.readDouble();
payrollFile.writeString(name);
payrollFile.writeDouble(payrate);
payrollFile.writeDouble(hours);
JOptionPane.showInputDialog("Would you like to enter another employee? (yes/no)");
answer = k.readString();
}while (answer.equalsIgnoreCase("yes"));
payrollFile.close();
}
}