Question: Create the Student class with methods and attributes given in the PowerPoint. (You can call two Students equal if they have the same ID number).

Create the Student class with methods and attributes given in the PowerPoint. (You can call two Students equal if they have the same ID number).

Create a Graduate class (this is different from the PowerPoint which has a Masters and a Doctorate class, but let us just have one, derived from Student, and add another attribute (a String) called degree, which is either "Masters" or "Doctorate", and a boolean called thesis (meaning whether they have completed their thesis and initially set to false).

Submit your L11a project.

Here is the correct main method for this lab L11a.docxCreate the Student class with methods and attributes given in the PowerPoint.

public static void main(String[] args) {

File inFile = new File("student.in");

Scanner fileInput = null;

try {

fileInput = new Scanner(inFile);

} catch (FileNotFoundException ex) {

//Logger.getLogger(Lab10.class.getName()).log(Level.SEVERE, null, ex);

}

//input student into an ArrayList

ArrayList myList = new ArrayList();

while(fileInput.hasNext())

{ int id=fileInput.nextInt();

String name=fileInput.nextLine();

Student s=new Student(name, id);

myList.add(s);

}

System.out.println();

System.out.println("Students not sorted");

for(int i=0; i

{

myList.get(i).writeOutput();

}

Collections.sort(myList);

System.out.println();

System.out.println("Students sorted");

for(int i=0; i

{

myList.get(i).writeOutput();

}

fileInput.close();

inFile = new File("graduate.in");

try {

fileInput = new Scanner(inFile);

} catch (FileNotFoundException ex) {

//Logger.getLogger(Lab10.class.getName()).log(Level.SEVERE, null, ex);

}

//input student into an ArrayList

ArrayList myG = new ArrayList();

while(fileInput.hasNext())

{ int id=fileInput.nextInt();

String MD = fileInput.next();

String thesis = fileInput.next();

String name=fileInput.nextLine();

Graduate g=new Graduate(name, id, MD, thesis);

myG.add(g);

}

System.out.println();

System.out.println("Graduates not sorted");

for(int i=0; i

{

myG.get(i).writeOutput();

}

Collections.sort(myG);

System.out.println();

System.out.println("Graduates sorted");

for(int i=0; i

{

myG.get(i).writeOutput();

}

fileInput.close();

}

In JAVA

Code must have

Correct attributes

Default constructor

Constructors with parameters

Accessors

Mutators

writeOutput

correctly derive classes(You can call two Students equal if they have the same ID

public boolean equals(Object otherObject) boolean isEqual = false; if ((otherObject != null) && (otherObject instanceof Student)) Student otherStudent = (Student)otherObject; is Equal = this.sameName(otherStudent) && (this.studentNumber == otherStudent.studentNumber); return isEqual; public boolean equals(Object otherObject) boolean isEqual = false; if ((otherObject != null) && (otherObject instanceof Student)) Student otherStudent = (Student)otherObject; is Equal = this.sameName(otherStudent) && (this.studentNumber == otherStudent.studentNumber); return isEqual

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!