I dont get it..why is the error: Exception in thread "main" java.util.Input MismatchExcepti on
this is my code
this is whats inside of my grade.txt
5
a b 75.0 76.0 77.0 78.0 79.0
c d 74.0 75.0 77.0 78.0 79.0
e f 70.0 72.0 73.0 74.0 75.0
g h 90.0 89.0 73.0 67.0 89.0
i j 78.0 77.0 75.0 66.0 87.0
this is the error :
Exception in thread "main" java.util.Input MismatchExcepti on
at java.util.Scann er.throwFor(Sca nner.java:819)
at java.util.Scann er.next(Scanner .java:1431)
at java.util.Scann er.nextInt(Scan ner.java:2040)
at java.util.Scann er.nextInt(Scan ner.java:2000)
at Adamos.main(Ada mos.java:22)
Process completed.
why is that the error? I don't get it?
this is my code
Code:
/** * @(#)textFileRead.java * * * @author * @version 1.00 2008/10/17 */ import java.io.*; import java.util.*; public class Adamos { static Scanner console = new Scanner(System.in); public static void main(String[]args) throws FileNotFoundException { Scanner inFile = new Scanner("C:\\Documents and Settings\\elson.KINGJIM\\Desktop\\grade.txt"); int num,count=0; double tot=0.0; num = inFile.nextInt(); double sum = 0.0; double sort[] = new double[num]; double grade[] = new double[num+1]; for(int i=0;i<num;i++) { int temp = 0; String frstName =inFile.next(); String lstName = inFile.next(); double g1 = inFile.nextDouble(); grade[temp++] = g1; double g2 = inFile.nextDouble(); grade[temp++] = g2; double g3 = inFile.nextDouble(); grade[temp++] = g3; double g4 = inFile.nextDouble(); grade[temp++] = g4; double g5 = inFile.nextDouble(); grade[temp++] = g5; tot=g1+g2+g3+g4+g5; sum=tot/temp; if(sum>=75) { System.out.printf("\n%.2f %s %s Passed",sum,frstName,lstName); sort[count++] = sum; } else { System.out.printf("\n%.2f %s %s Failed",sum,frstName,lstName); sort[count++] =sum; } } System.out.println("\n\nSorted Average"); System.out.print("-----------------------------\n"); Arrays.sort(sort); for(int i=0;i<sort.length;i++) { System.out.println(" "+sort[i]); } System.out.println(); inFile.close(); } }
5
a b 75.0 76.0 77.0 78.0 79.0
c d 74.0 75.0 77.0 78.0 79.0
e f 70.0 72.0 73.0 74.0 75.0
g h 90.0 89.0 73.0 67.0 89.0
i j 78.0 77.0 75.0 66.0 87.0
this is the error :
Exception in thread "main" java.util.Input MismatchExcepti on
at java.util.Scann er.throwFor(Sca nner.java:819)
at java.util.Scann er.next(Scanner .java:1431)
at java.util.Scann er.nextInt(Scan ner.java:2040)
at java.util.Scann er.nextInt(Scan ner.java:2000)
at Adamos.main(Ada mos.java:22)
Process completed.
why is that the error? I don't get it?
Comment