import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.Locale;
public class ScanSum {
public static void main(String[] args) throws IOException {
Scanner s = null;
double sum = 0;
try {
s = new Scanner(
new BufferedReader(new FileReader("usnumbers.txt")));
s.useLocale(Locale.US);
while (s.hasNext()) {
if (s.hasNextDouble()) {
sum += s.nextDouble();
} else {
s.next();
}
}
} finally {
s.close();
}
System.out.println(sum);
}
}
and when I try to compile using javac (same result using gcj) I get this
----------
1. ERROR in ScanSum.java (at line 35)
import java.util.Scanner;
^^^^^^^^^^^^^^^^^
The import java.util.Scanner cannot be resolved
----------
2. ERROR in ScanSum.java (at line 40)
Scanner s = null;
^^^^^^^
Scanner cannot be resolved to a type
----------
3. ERROR in ScanSum.java (at line 43)
s = new Scanner(
^^^^^^^
Scanner cannot be resolved to a type
----------
3 problems (3 errors)
Anyone knows what's going on? :(


Sign In
Create Account

Back to top










