Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a test class. It will read in students\' info from a file. The first line

ID: 3634906 • Letter: C

Question

Create a test class. It will read in students' info from a file. The first line of the file contains a number indicating how many students information are specified in the file. And the rest in the file contains information of each individual student. The test class will receive the name of the file through command line argument, create an array to store students info, read in the information from the file, and print out these students' info via calling the toString method.

Here is the Student Class I already did that part I just need the test class:
public class Student {

private String fName;
private String mName;
private String lName;
private String DOB;
private String UFID;

public Student(){
fName = "Sarah";
lName = "Smith";
DOB = "09/22/1990";
UFID = "5315-1289";
}

public void setNames(String name){

String[] list = name.split(" ");
if(list.length == 2){
fName = list[0];
lName = list[1];
}
else if(list.length == 3){
fName = list[0];
mName = list[1];
lName = list[2];
}
else
System.out.print("Please enter 2 or 3 names per student");
System.exit(1);
}

public String getName(){
if(mName == ""){
return lName + ", " + fName;
}
else return lName +", " + fName + " " + mName;
}

public void setUFID(String id){
if(id.matches("[0-9]\d{3}-[0-9]\d{3}")){
UFID = id;
}
else UFID = "Invalid ID";
}

public String getID(){
return UFID;
}

public void setDOB(String dob){
String[]date = dob.split("/");
if(date[0].length() < 3 && date[1].length()< 3 && date[2].length() == 4){
if(date[0].equals("02") || date[0].equals("2")){
int temp = Integer.parseInt(date[1]);
if(temp > 28) DOB = "Invalid Birthdate";
else DOB = dob;
}
else DOB = dob;
}
else DOB = "Invalid Birthdate";
}

public String getDOB(){
return DOB;
}

public String toString(){
String s = "";
s = String.format("Name: %s%nUFID: %s%n" +
"D.O.B: %s%n", this.getName(), this.getID(), this.getDOB());
return s;
}

public static void main(String[] args) {
Student s = new Student();
s.setNames("Timothy Cecil Armstrong");
s.setUFID("0134-1234");
s.setDOB("02/12/1990");
System.out.print(s.toString());
}

}

Explanation / Answer

This is my code I wrote for you last night.. I included the main inside the student class.. all you need to do is to copy that into another class if you'd like if not the test is within the student class.. thats somewhat a shame I spent all that time on this code and you just copied what I wrote and didn't rate me anything.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote