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

File Edit Format View Help Student ID# First Name 123 150 Tim Diablo Tom Buffy L

ID: 3730273 • Letter: F

Question

File Edit Format View Help Student ID# First Name 123 150 Tim Diablo Tom Buffy LeRoy Bruce Tom Dick Harry ane Last Name Smith Ho Doe slayer Jackson Lee Smith Smith Ho Doe DOB 19960215 19900420 19860215 19960314 20001114 19560215 19890130 19880615 19870420 19860210 Address 777 Heavens way 666 Hel1s Gate 999 Nevermind 456 Seven 123 Right Here Alley 333 Enter the Dragon 321 zero 836 Pick Up Sticks 577 Eleven 888 Haight 100 25 849 123 123 150 643 Create a Student Parent Class Create subclasses as needed and determine access for class elements. 3 Digit Student ID#, First Name, Last Name, DOB, and Address Create a subclass containing methods for accessing and outputting Street Address. Create a subclass containing Student Names Override the method for printing in each class to display the required print information. Create a subclass and methods as needed. Create the ability to search a student in the file by Last Name

Explanation / Answer


public class StudentChild extends StudentSuper {


static List<StudentSuper> studentList = new ArrayList<>();

public static boolean searchByLastName ( String name){

for(StudentSuper ss : studentList){


if(ss.getLastName().equalsIgnoreCase(name)){

return true;
}

}
return false;

}


public static void printStudentNames(){

for(StudentSuper ss : studentList){

System.out.println("First Name : " + ss.getFirstName() + " Last Name : " + ss.getLastName());

}
}

public static void printStudentAddress(){

for(StudentSuper ss : studentList){

System.out.println("Address : " + ss.getStreatAddress());

}
}

public static void printAllStudentInfo(){

for(StudentSuper ss : studentList){

System.out.println(ss.toString()+" ");

}
}

public static void loadStudentDetails() throws FileNotFoundException{

Scanner scan = new Scanner (new File("Student_Details.txt");
boolean first = true;

while(scan.hasNextLine()){

if(first){

first = false;
scan.nextLine();
continue;
}else{

String student = scan.nextLine();
String[] studArray = student.split(" ");
StudentSuper ss = new StudentSuper ();
ss.setStudentID(Integer.parseInt(studArray[0]));
ss.setFirstName(studArray[1]);
ss.setLastName(studArray[2]);

ss.setdObBirth(studArray[3]);
ss.setStreatAddress(studArray[4]);

studentList.add(ss);

}

}
}

public static void main (String []args){

loadStudentDetails();
do{
System.out.println("********************");
System.out.println("*Main Menu *");
System.out.println("* 1) Print student name*");
System.out.println("* 2) Print student address *");
System.out.println("* 3)Print all student info *");
System.out.println("* 4) Search by last name*");
System.out.println("* 5) Sort current selection ");
System.out.println("* 6) Quit *");
System.out.println("Enter choice ");
  
Scanner scan = new Scanner(System.in);
int option = scan.nextInt();
  
switch(option){
  
case 1:
  
printStudentNames();
break;
case 2:
printStudentAddress();
break;
case 3:
printAllStudentInfo();
break;
case 4:
System.out.println("Enter last name");
String name = scan.next();
System.out.println("Name " + name + (searchByLastName(name)?" Found " : "Not found"));
break;
case 5:
break;
case 6:
System.exit(0);
  
}

}while(true);


}

}

=======

public class StudentSuper{

int studentID;
String firstName;
String lastName;
String dObBirth;
String streatAddress;

public int getStudentID(){

return studentID;

}

public String getFirstName(){

return firstName;

}

public String getLastName(){

return lastName;

}

public String getdObBirth(){

return dObBirth;

}

public String getStreatAddress(){

return streatAddress;

}

public void setStudentID(int studentID){

this.studentID = studentID;

}

public void setFirstName(String firstName){

this.firstName = firstName;

}

public void setLastName(String lastName){

this.lastName = lastName;

}

public void setdObBirth(String dObBirth){

this.dObBirth = dObBirth;

}

public void setStreatAddress(String streatAddress){

this.streatAddress = streatAddress;

}

@Override
public String toString(){

return "Name: " + this.getFirstName() + " " + this.getLastName() + " " + "Student ID: " + this.getStudentID() + " " + "DOB: " + this.getdObBirth() + " " + "Address: " + this.getStreatAddress();

}
}

***********************************************************

*Main Menu *

Enter # to run the program or quit *

1) Print Student Name *

2) Print Student Address *

3) Print All student info *

4) Search by last name *

5) Sort current selection *

6) Quit *

***********************************************************

Enter choice: 1

First Name: Tim Last Name: Smith

First Name: Diablo Last Name: Ho

***********************************************************

*Main Menu *

Enter # to run the program or quit *

1) Print Student Name *

2) Print Student Address *

3) Print All student info *

4) Search by last name *

5) Sort current selection *

6) Quit *

***********************************************************

Enter choice: 3

Name: Tim Smith

Student ID: 123

DOB: 19960215

Address: 777 Heavenway

Name: Diablo Ho

Student ID: 150

DOB: 19900420

Address: 666 Hells Gate

***********************************************************

*Main Menu *

Enter # to run the program or quit *

1) Print Student Name *

2) Print Student Address *

3) Print All student info *

4) Search by last name *

5) Sort current selection *

6) Quit *

***********************************************************

Enter choice: 4

Enter Last Name to search: Ho

Name Ho Found

***********************************************************

*Main Menu *

Enter # to run the program or quit *

1) Print Student Name *

2) Print Student Address *

3) Print All student info *

4) Search by last name *

5) Sort current selection *

6) Quit *

***********************************************************

Enter choice: 2

Address 777 Heavenway

Address 666 Hells Gate

***********************************************************

*Main Menu *

Enter # to run the program or quit *

1) Print Student Name *

2) Print Student Address *

3) Print All student info *

4) Search by last name *

5) Sort current selection *

6) Quit *

***********************************************************

Enter choice: 6

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