this is my code
Expand|Select|Wrap|Line Numbers
- /**
- * @(#)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.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:819)
at java.util.Scanner.next(Scanner.java:1431)
at java.util.Scanner.nextInt(Scanner.java:2040)
at java.util.Scanner.nextInt(Scanner.java:2000)
at Adamos.main(Adamos.java:22)
Process completed.
why is that the error? I don't get it?