Question: Edit Driver class an implement the following methods 1. public static MyStudent[] copy(MyStudent[] original) - make a deep copy of every MyStudent object in the

Edit Driver class an implement the following methods

1. public static MyStudent[] copy(MyStudent[] original) - make a deep copy of every MyStudent object in the original array and then return

that copy. Any changes made to the copy should not affect the original at all.

2. Public static double printAverages(MyStudent[] original)- this method must print out the average score for each MyStudent.

You must print out the person's name followed by a colon and then followed by the average score for that person. The method then returns the average of all students and all scores.

//Driver class below

import java.util.Random; public class Driver{ public static void main(String args[]){ Random rand = new Random();

MyStudent[] students = new MyStudent[4]; for(int i=0; i<4; i++){ //create a new student students[i] = new MyStudent(10); //give that student a random age between 10 and 60 students[i].setAge(rand.nextInt(51) + 10); for(int j=0; j<10; j++){ //give that student random scores between 0 and 50 students[i].setScore(rand.nextInt(51), j); } }

students[0].setName("John"); students[1].setName("Jane"); students[2].setName("Jen"); students[3].setName("Jake"); } }

//MyStudent class below

public class MyStudent{ private int[] scores; private int age; private String name; public MyStudent(int numScores){ age = 0; name = ""; scores = new int[numScores]; } public int getAge(){ return age; } public void setAge(int age){ this.age = age; } public int[] getScores(){ return scores; } public void setScore(int score, int location){ scores[location] = score; } public String getName(){ return name; } public void setName(String name){ this.name = name; } }

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!