So I have a Student class, and I have to get the best and scores from the students, but it's all grouped by their courseid. Basically I have to get the best and worst score in each specific course. Everything is taken from a file students.txt and this is my code so far.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
public class Main
{
public static void main(String[] args) throws IOException {
Path path = Paths.get("src/students.txt");
List<String> lines = Files.readAllLines(path);
ArrayList<Student> students = new ArrayList<>();
for (String line:lines) {
String[] rawlines = line.split(",");
String name = rawlines[0];
String lname = rawlines[1];
String courseID = rawlines[2];
String score = rawlines[3];
double doublescore = Double.parseDouble(score);
Student student = new Student(name, lname, courseID, doublescore);
students.add(student);
}
for (Student s : students) {
System.out.println(s);
}
}
}
Also I need to use threads to make this parallel, but that's not my main concern right now.
The lines in the file are set up like this: Joe, Doe, CS280, 92