I am not professional in java but I tried my best. My code reads a text file then it puts into an array then put each of its indexes into an array list but my problem I have to access an element of that array because my array looks like this (name,last name,quiz1,quiz2, midterm, project, final, average) Actually my ArrayLists first element like this so, for example, I tried to access midterm result and then print it to a table.
static List<Assign2> studentList = new ArrayList<>();
public static void main(String [] args) throws IOException{
new myClass();
File here = new File(".");
System.out.println(here.getAbsolutePath());
BufferedReader reader = new BufferedReader(new FileReader("A.txt"));
String line= reader.readLine();
String[] arr =line.split(",");
Object[] data = {arr[0],arr[1],arr[2],arr[3]};
//studentList.add(Arrays.asList(data));
}
public static void table(List<myClass> b){
System.out.printf("%-20s %-20s %-20s %-20s %-20s %-20s %-20s %-20s %-20s %-20s", "NAME","LAST NAME","ID","QUIZ1","QUIZ2","PROJECT","MIDTERM","FINAL","AVERAGE","LETTER GRADE");
System.out.println();
System.out.println("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
for(int i=0;i<b.size();i++){
System.out.printf("%-20s %-20s %-20s %-20s %-20s %-20s %-20s %-20s %-20s %-20s",b.get(i).getName(),b.get(i).getLastName(),b.get(i).getID(),b.get(i).getQuiz1(),b.get(i).getQuiz2(),b.get(i).getProject(),b.get(i).getMidterm(),b.get(i).getFinalGrade(),b.get(i).getAverage(),b.get(i).getLetterGrade());
System.out.println();
}
}