1. No change in the Student class 2. Change in the StudentList class to read the
ID: 3723948 • Letter: 1
Question
1. No change in the Student class
2. Change in the StudentList class to read the data from a file (outside of the student class) named StudentGrades.txt which contains the following data (instead of hard-coding the data)
Edna
57 74 73 85 86 65 99
Edmund
75 61 94 53 68 76 73
Sadie
49 69 67 80 99 78 70
Olive
88 87 42 62 44 81 46
Dianna
76 100 98 60 72 94 99
Roderick
81 70 29 53 72 1 18
Cameron
84 1 5 21 10 27 93
Rafael
96 4 97 67 37 44 34
Isaac
68 57 45 40 25 83 63
Darla
76 6 1 17 35 12 38
Renee
59 34 22 54 50 80 28
Neil
40 100 49 93 42 86 9
Carmen
9 72 35 85 17 22 34
Cecelia
3 96 24 10 96 31 91
Kerry
4 49 53 31 31 87 90
Explanation / Answer
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; //======================================================================== public class StudentList { //-------------------------------------------------- private Student[] studentList; private String[] names = {"Edna", "Edmund", "Sadie", "Olive", "Dianna" }; private int[][] testScores = { {57, 74, 73, 85, 86, 65, 99 }, {75, 61, 94, 53, 68, 76, 73 }, {49, 69, 67, 80, 99, 78, 70 }, {88, 87, 42, 62, 44, 81, 46 }, {76, 100, 98, 60, 72, 94, 99 }}; //-------------------------------------------------- public StudentList() { Scanner in = null; try { in = new Scanner(new File("StudentGrades.txt")); int size = 0; while (in.hasNextLine()) { size++; } size /= 2; studentList = new Student[size]; String name; int scores[]; in.reset(); for(int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.