I compiled this program with no error, but when I run it give me some kind of problem where I have: idNumber = inFile.nextInt(); //student ID number. Appreciate any help. Thanks
/*
*Description: Writing own method, Switch Selection Control, String,Accumulating,
*Counting method, array base on last reviews from previous labs.
*prepare a grade report for more than 1 student using input File and
*output to a File with print outs letter grades # of A's, B's etc.
*Input: College Name, Student Name, Student ID Number and
*Courses-Section Name (ex. CISC115.59), Letter Grades
*Output: College Name, Student Name, Student ID Number;
*Courses, Letter Grades, Grade Points, GPA and total students grades.
*/
import java.io.*; //Needed for File classes
import java.util.*; //Needed for scanner classes
public class gpa
{
public static void main(String[] args)throws Exception
{
int idNumber; //student ID number
String Name; //student name
int numStudents; //number of total students
int n=0; //total of courses of each student
String courseName; //course name
String letGrade; //course letter grade
double gp=0.0; //gradepoints
double totalgp = 0.0;//total gradepoints
double gpa = 0.0;//GPA
// declare inFile & associate with actual data file
Scanner inFile = new Scanner(new FileReader("inputgpa.txt"));
//Read numStudents from first line of inputgpa file
numStudents = inFile.nextInt(); //total number of students
// declare outFile & associate with actual data file
PrintWriter outFile = new PrintWriter("outputgpa.txt");
//Print College name to file
outFile.println(" "+"Grade Report for "+ numStudents+" students");
// Continue if there is more data in inputgpa file
while (inFile.hasNext())
{
//Read Name & idNumber from inputgpa file
Name = inFile.nextLine(); // student name in file
idNumber = inFile.nextInt(); //student ID number
// Output to file
outFile.println("\t\t\t"+Name);
outFile.println("\t\t\t"+idNumber);
//print 1 blank line
outFile.println();
//Write to file for headings
outFile.println("Couse\t\t"+"Grade\t\t"+"Gradepoints");
//total student courses
n = 6;
int i=0;
//numbers of total of A, B, C, D & F
int gpA=0;
int gpB=0;
int gpC=0;
int gpD=0;
int gpF=0;
//start loop
for(i=0; i<n; i++)
{
//read courseName
courseName = inFile.next();
letGrade = inFile.next();
//change letGrade variable to character
char g = letGrade.charAt(0);
//compute gp from input letGrade
switch(g)
{
case 'A': gp=4; gpA++; break;
case 'B': gp=3; gpB++; break;
case 'C': gp=2; gpC++; break;
case 'D': gp=1; gpD++; break;
case 'F': gp=0; gpF++; break;
default: System.out.println("Invalid Grade");
}//End switch loop
//compute to find total gradepoints
totalgp+= gp;
//Read values then output to outputgp file
outFile.println(courseName+"\t\t"+letGrade+"\t\t"+gp);
}//End For loop
//Compute gpa
gpa = totalgp / n;
//Read gpa and output to outputgpa file
//print line
outFile.println("-------------------------------");
//display gpa as footer
outFile.println("GPA: "+gpa);
//print divider for output the summary of letGrade blank lines
outFile.println();
outFile.println();
outFile.println();
outFile.println("____________________________________");
outFile.println("The Grades sort out for all the students at BCCC "+ "this Spring semester are: " );
outFile.println(gpA+", "+gpB+", "+", "+gpC+", "+gpD+", "+gpF);
}//End While loop then close the inputgpa file
inFile.close();
}//End Main method
}