Hi, at the moment I have this:
import java.util.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.FileReader;
public class StudentID {
public static void main(String[] args)throws Exception{
System.out.println ("Please enter StudentID: ");
BufferedReader reader = new BufferedReader (new FileReader("CW2_data.csv"));
File file = new File("CW2_data.csv");
try {
BufferedReader r = new BufferedReader(
new InputStreamReader(
new FileInputStream("CW2_data.csv")));
String line;
while((line = r.readLine()) != null)
System.out.println(line);
r.close();
} catch(IOException e) {
System.out.println(" There was an Error Reading the file. " + e.getMessage());
}
}
}
I am trying to get the program to prompt the user for its StudentID, then search through the data file for that StudentId and return their marks for all the modules. Unfortunatly all my codes does is list the whole file back to me.
I tried to add StudetnID=Userinput.readstring;
right after so that user was given an opertunity to type in the username but then I realise that wouldn't work unless I tell it scan the whole document for it. I was reading up on maps (as recomendeded by user on here) but I still haven't got to grips with it and I don't know if it would it even work here. The data file is in form of 3 columns and about 282 rows of data, ie
UserID: Module: Mark
ab006, GYH095, 56
Any help would appreciated.