I need 13b code.Solution of 13 a is below: public class StudentInfo { private St
ID: 3867021 • Letter: I
Question
I need 13b code.Solution of 13 a is below:
public class StudentInfo {
private String id;
private boolean isUST;
private int[] scores;
public StudentInfo(String id, int s1, int s2, boolean isUST) {
this.id = id;
this.isUST = isUST;
scores = new int[2];
scores[0] = s1;
scores[1]=s2;
}
}
Please do 13b and attach code and screesnhot
COMP1022P Final Summer 2016-17 The course class is designed to contain an array of n students. Complete the implementation readRecords) so that reads file . of the (method it the " "namelisttxt, and stores information the student array, studentListinside the course class. the into import java.io, *; import java.util. Scanner; public class course { private student studentList; public course int n) { studentList new student [n]; } I read all records from file and add it to studentList public void readRecords() throws IOException { 1N create a File object for input "namelist.txt " IN construct a Scanner object on the file int numStudent = 0; I continue to read from the file if there is a line to I read. You may assume that the 4 entries in the line always / exist are of the correct type. Create a student object I with the correct parameters and add it to student List for I each line read. while ) { fileScanner.close() ;/release input file Page 11Explanation / Answer
public void readRecords() throws IOException{
// create a File object for input "namelist.txt"
File file = new File("namelist.txt");
// construct a Scanner object on the file
Scanner fileScanner = new Scanner(file);
int numStudent = 0;
// Continue to read from file if there is a line to
// read......
String[] studentFields;
Student student;
while ((fileScanner.hasNextLine()) {
studentFields = scanner.nextLine().split(" ");
student = new Student(studentFields[0], studentFields[1], studentFields[2], studentFields[3]);
studentList.add(student);
numStudent++;
}
fileScanner.close(); // release input file
file.close();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.