can't get my file to read correctly.. keep getting mismatch error
below will be my code and the file it is supposed to read.. I can't get it to
work.It keeps giving me a mismatch error.
import java.util.*;
import java.io.*;
public class TestStudent{
public static void main(String[] args){
try {
Scanner s = new Scanner(new File("StudentGrades.txt"));
if(s.hasNext()){
String title = s.next(); //throws away the title line
}
s.useDelimiter("[,\\n+]");
while(s.hasNext()){
String name = s.next();
int id = s.nextInt();
double attGr = s.nextDouble();
double hwGr = s.nextDouble();
double e1Gr = s.nextDouble();
double e2Gr = s.nextDouble();
double fExGr = s.nextDouble();
System.out.println(name+attGr+hwGr+e1Gr+e2Gr+fExGr);
//Construct the Student object based on the above data
}
}
catch(Exception e){
System.out.println(e);
}
}
file:: Studentgrades.txthas this info in it
Name,id,attGr,HkGr,E1Gr,E2Gr,FExGr
Alex Smith,111111,75,80,75,78,73
Mary Alexander,222222,95,90,87,93,85
Johnson White,333333,80,80,75,67,73
Andrew Black,44444,95,85,86,93,95
Gary Shippment,55555,86,78,87,72,68
Walter Green,666666,67,90,90,95,85
Mario Winter,777777,95,90,95,87,92
Henry Summer,888888,87,100,85,83,72
Michel Spring,999999,56,100,75,78,85
April May,112222,40,85,65,55,65
May Spring,113333,25,65,50,45,50
Helen Hunter,114444,79,88,66,73,67
Ammy Gram,115555,87,90,90,87,95
Bill Bonnet,223333,95,100,95,82,95
Larry Smith,224444,100,87,73,80,76
Julia Winter,334444,35,75,55,63,70
Suzan Snow,335555,67,65,40,65,60
Gary Carpenter,336666,98,80,65,78,83
Last Not Least,337777,97,90,87,94,88

