我正在制作一个程序,用于查看文本文件并将其打印到 eclipse 中的控制台。文本文件中的一行看起来像这样......
A.马修斯 4 7 3 10 14 50
运行程序时,我收到这样的错误..
这是程序
import java.io.*; // for File
import java.util.*; // for Scanner
public class MapleLeafLab {
public static void main(String[] args) throws FileNotFoundException {
Scanner input = new Scanner(new File("mapleleafscoring.txt"));
while (input.hasNextLine()) {
String line = input.nextLine();
Scanner lineScan = new Scanner(line);
String name = lineScan.next(); // e.g. "Eric"
String rest = lineScan.next();
int GP = lineScan.nextInt(); // e.g. 456
int G = lineScan.nextInt();
int A = lineScan.nextInt();
int P = lineScan.nextInt();
int S = lineScan.nextInt();
Double SS = lineScan.nextDouble();
System.out.println(name+rest+" "+GP+" "+G+" "+A+" "+P+" "+S+" "+SS);
//System.out.println(name + " (ID#" + id + ") worked " +
// sum + " hours (" + average + " hours/day)");
}
}
}
慕桂英4014372
相关分类