import java.io.*;
import java.util.*;
public class Exercise3_2
{
public static void main(String[] args) throws FileNotFoundException
{
String firstName;
String lastName;
double score1, score2, score3, score4, score5;
double avg;
Scanner inFile = new Scanner(new FileReader("test.txt"));
PrintWriter outFile = new PrintWriter ("testavg.out");
firstName = inFile.next();
lastName = inFile.next();
outFile.println("Student name : " + firstName + " " + lastName);
score1 = inFile.nextDouble();
score2 = inFile.nextDouble();
score3 = inFile.nextDouble();
score4 = inFile.nextDouble();
outFile.println("Test scores: " + score1 + " ," + score2 + " ," + score3
+ " ," + score4);
avg = (score1 + score2 + score3 + score4) / 4;
outFile.printf("Average test scores: %5.2f %n, avg");
inFile.close();
outFile.close();
}
}
每当我运行这个,这就是我得到的: 线程" main"中的例外情况java.io.FileNotFoundException:test.txt(系统找不到指定的文件)
...... WHY !!!!