Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5Write **TWO** programs. ********* PROGRAM 1: CreateBinaryUsingDataStream.java (1) Read students.txt that contains students' information. Each student' info consists of two lines: name and classification. -
5Write **TWO** programs. ********* PROGRAM 1: CreateBinaryUsingDataStream.java (1) Read "students.txt" that contains students' information. Each student' info consists of two lines: name and classification. - Use a Scanner to read the text file. - Store each student's information in a Student object and then add the Student object in an array list of Student. (2) Create a binary file "studentsDataStream.dat" using DataOutputStream. The program will need to write attribute by attribute to the file. ********* PROGRAM 2: ReadBinaryUsingDataStream.java It will read Student objects from the binary file created by Program 1 and print out the information for each student. In order to earn full credits, the program shouldn't assume knowledge that there are six Student objects are in the file. If your program read exactly 6 Student object, you can still earn partial credits for Program 2.
public class Student { private String name; private int classification; public Student(String name, int classification) { this.name = name; this.classification = classification; } public String getName() { return name; } public int getClassification() { return classification; } @Override public String toString() { return String.format("Student: %s %d", name, classification); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started