Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.
Can Anyone Help me ??
the problems is i dont know how to store it
its keeping coming up null in the storing
also in the switch.
the strings have to be converted into ints depending on the rate of excellence.
the code is below
public void readMarksData(String fileName)throws FileNotFoundException
{
File dataFile = new File (fileName);
Scanner scanner = new Scanner(dataFile);
//System.out.println(scanner.nextLine());
cohortName = scanner.nextLine();
int responces = scanner.nextInt();
scanner.nextLine();
//int numberOfStudentResponses=scanner.nextInt();
//System.out.println("Number of Student Responces " + responces);
testMarks = new int [responces][10];
int num;
for(int add=0; add<8; add++)
{
Scanner scanner2 = new Scanner(scanner.nextLine()).useDelimiter("[ ]*(,)[ ]*");
for (int columns =0; columns<10; columns ++){
for(int i =0; i<4; i++){
switch(scanner2.next())
{
case "excellent": num=5; break;
case "very good": num=4; break;
case "good": num=3; break;
case "average": num=2; break;
case "poor": num=1; break;
default : num=0; break;
}
testMarks[add][columns+num] = scanner.nextInt();
}
}
scanner2.close();
scanner.close();
}
}