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

Java: Please help with the following assignment. Thank you so much. Activity: 1.

ID: 3750715 • Letter: J

Question

Java: Please help with the following assignment. Thank you so much.

Activity: 1. Review Chapter 9 and Chapter 9 examples. 2. Add a name field (type String) to your Student class and convert it into an abstract class with an abstract method hoursLeft) 3. Create another subclass of Student called GraduateStudent with an additional instance field 1. foundationHours - int 4 Create default and a fully parameterized constructur for GraduateStudent as well as setter/getter methods for the new instance field 5. Override the hoursLeft) method, such that it now shows the hours 6. Create toString() Methods inside the CSStudent and the 7. Create a new StudentTester class remaining after the student took the foundation classes. GraduateStudent classes showing the class and the name. 1. Convince yourself that you cannot create an instance of Student anymore (try it and make sure you understand the error message) 2. Create an Array of type Student] with space for five Student instances 3. Fill it with 3 CSStudent and 2 GraduateStudent instances.

Explanation / Answer

Note : Bro could u provide details about CSStudent class so that i can create and add that to the Student array(As per the Requirement).

_______________

Student.java

public abstract class Student {

//Declaring instance variables

private String name;

//Zero argumented constructor

public Student() {

}

//Abstract Method

public abstract int hoursLeft();

//Parameterized constructor

public Student(String name) {

this.name = name;

}

// getters and setters

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

//toString method is used to display the contents of an object inside it

@Override

public String toString() {

return "Student [name=" + name + "]";

}

}

__________________

GraduateStudent.java

public class GraduateStudent extends Student {

//Declaring instance variables

private int foundationHours;

//Zero argumented constructor

public GraduateStudent() {

}

//Parameterized constructor

public GraduateStudent(String name, int foundationHours) {

super(name);

this.foundationHours = foundationHours;

}

// getters and setters

public int getFoundationHours() {

return foundationHours;

}

public void setFoundationHours(int foundationHours) {

this.foundationHours = foundationHours;

}

@Override

public int hoursLeft() {

return 45-foundationHours;

}

//toString method is used to display the contents of an object inside it

@Override

public String toString() {

return super.getName()+", Hours Remaining =" + hoursLeft();

}

}

_________________

Test.java

public class Test {

public static void main(String[] args) {

//Creating an Array of 5 Graduate Students

Student st[]={new GraduateStudent("John", 10),

new GraduateStudent("Sam", 7),

new GraduateStudent("Mills", 5),

new GraduateStudent("Ken", 12),

new GraduateStudent("Bob", 15)};

//Displaying the output

for(int i=0;i<st.length;i++)

{

System.out.println(st[i]);

}

}

}

_________________

Output:

John, Hours Remaining =35
Sam, Hours Remaining =38
Mills, Hours Remaining =40
Ken, Hours Remaining =33
Bob, Hours Remaining =30

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