Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This programming question is a continuation of Assignment # 5 - a. 1. Write a class Node (which represents a single Node in a Binary

This programming question is a continuation of Assignment # 5 - a.

1. Write a class Node (which represents a single Node in a Binary Tree).

2. Write a class StudentTree (a binary Tree of students, based on their IDs), which has the following public recursive methods:

a) Insert (Notice that it is not allowed to have a duplicated IDs)

b) Print the whole Tree (In-Order Traversal). c) Compute the maximum quizzes average grade over all students.

d) Change the GPA of a certain student (given his/her ID)

e) Compute the average GPA for all students.

f) Save students into a given binary file name.

3. Update the test class in such a way to comply with the following:

a) Implement a static method printFile that takes a string f1 representing a serial file name of Student objects and print all objects inside that file.

b) Implement a static method loadStudents that takes a string f1 representing a serial file name of Student objects, read all objects from the file, insert them into a Tree of student, and return the tree.

c) In main method:

i. Creates a binary file with name student.ser of seven Student objects.

ii. Print the file student.ser (using a call to printFile method).

iii. Create an instance of StudentTree

iv. Load students from the binary file into the tree (using a call to method loadStudents)

v. Test all other methods on StudentTree , try to insert and update some records, then save all change into a binary file (using method save in 2-f)

vi. Print the result binary file after applying save method in 2-f (using a call to printFile method).

Make sure to handle WrongQuizGradeException (by using try-catch).

================ this is my sol for Assignment # 5 - a. ===== public class WrongQuizGradeException extends Exception { WrongQuizGradeException(){ System.err.println("Quizz Grade Must Be Between 0 and 10!!!!"); } } == public class Student { private String name; private Integer ID; private Double GPA; private ArrayList GradesList=new ArrayList();

Student (String name, Integer ID, Double GPA){ this.name=name; this.ID=ID; this.GPA=GPA; } public void SetName(String n) { name=n;} public void SetID(Integer id) {ID=id;} public void SetGPA(Double GPA) {this.GPA=GPA;} public String getName() {return name;} public Integer getID() {return ID;} public Double getGPA() {return GPA;} public void addQuiz (double grade) throws WrongQuizGradeException { if (grade<0 || grade>10) { throw new WrongQuizGradeException(); } GradesList.add(grade); } public double quizzesAvg() { Iterator I=GradesList.iterator(); double sum=0.0; while (I.hasNext()) { sum+=I.next(); } return sum/GradesList.size(); } public void Print() { System.out.println("Name: "+name+" ID: "+ID+" GPA: "+GPA); System.out.println("The Quizes Grades:"); Iterator I=GradesList.iterator(); while (I.hasNext()) { System.out.print(I.next()+" "); } System.out.println(" The Avg: "+quizzesAvg()); } } == public class Test { public static void main(String[] args) { Student S=new Student ("Ali",67,3.0); try { S.addQuiz(9); } catch (WrongQuizGradeException e) { e.getMessage(); } try { S.addQuiz(11); } catch (WrongQuizGradeException e) { e.getMessage(); } try { S.addQuiz(7); } catch (WrongQuizGradeException e) { e.getMessage(); } try { S.addQuiz(-1); } catch (WrongQuizGradeException e) { e.getMessage(); } try { S.addQuiz(5); } catch (WrongQuizGradeException e) { e.getMessage(); }

S.Print(); } }

______________________ I need help with the below

*** You have to submit a full report and give a presentation on your work. *** This programming question is a continuation of Assignment # 5 - a. 1. Write a class Node (which represents a single Node in a Binary Tree). 2. Write a class StudentTree (a binary Tree of students, based on their IDs), which has the following public recursive methods: a) Insert (Notice that it is not allowed to have a duplicated IDs) b) Print the whole Tree (In-Order Traversal). c) Compute the maximum quizzes average grade over all students. d) Change the GPA of a certain student (given his/her ID) e) Compute the average GPA for all students. f) Save students into a given binary file name.

3. Update the test class in such a way to comply with the following: a) Implement a static method printFile that takes a string f1 representing a serial file name of Student objects and print all objects inside that file. b) Implement a static method loadStudents that takes a string f1 representing a serial file name of Student objects, read all objects from the file, insert them into a Tree of student, and return the tree. c) In main method: i. Creates a binary file with name student.ser of seven Student objects. ii. Print the file student.ser (using a call to printFile method). iii. Create an instance of StudentTree iv. Load students from the binary file into the tree (using a call to method loadStudents) v. Test all other methods on StudentTree , try to insert and update some records, then save all change into a binary file (using method save in 2-f) vi. Print the result binary file after applying save method in 2-f (using a call to printFile method). Make sure to handle WrongQuizGradeException (by using try-catch).

( in java program language) pls help

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago