Originally Posted by Fou-Lu
You pretty much need to chunk out three lines at a time, and drop them into the arrays in position 'i' for whatever iteration you are in.
A better option would be to use a collection though; arrays require manual resizing, and then you are splitting the data up between three separate arrays. Since the data has to represent something, you simply pull in three lines at a time, construct an object that represents it, and then provide that object to a list collection. Mucho easier than three arrays.
Can you tell me what is wrong with the following code, it won't run.
// Create File Object
String fileName = "file.txt";
File file = new File(fileName);
Scanner scan = new Scanner(file);
int counter = 0;
String code = scan.next();
String moduleName = scan.next();
double totalPurchase = scan.nextDouble();
moduleCodes[counter] = code;
moduleNames[counter] = moduleName;
numberOfStudents[counter] = totalPurchase;