Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The language is java. Please create a simple code using the prompt with all four questions. It shouldnt take long and this a study guide

The language is java. Please create a simple code using the prompt with all four questions. It shouldnt take long and this a study guide question to practice for the test. Thank you.

image text in transcribed

the provided classes needed are listed down below:

public class Course { private String title; private int courseNumber; private int grades[]; //initial values constructor public Course(String t, int cn, int g[]){ title=t; courseNumber=cn; grades=g; } //get methods public String getTitle(){return title;} public int getCourseNum(){return courseNumber;} public int[] getGrades(){return grades;} //method to find average grade public double Average(){ double sum=0; for(int i=0; i sum=sum+grades[i]; return sum/grades.length; // return average } //method that return maxim grade for a class public int maxGrade(){ int max=grades[0]; for(int i=1;i if(grades[i]>max) max=grades[i]; return max; } public String toString(){ return String.format("%3d %s",courseNumber,title); } } ---------------------------------------

public class Student { private String name; private Course listOfCourse[]; //initial valued constructor public Student(String n, Course list[]){ name=n; listOfCourse=list; } //get methods public Course[] getList(){return listOfCourse;} public String getName(){return name;} //method to determine best courses based on Average grade //method returns the course with best average grade public Course Best(){ Course c; c=listOfCourse[0]; for(int i=1;i if(c.Average() c=listOfCourse[i]; return c; }

//toString method public String toString(){ return name; } } ---------------------------------------

public class Instructor { private String name; private Student list[]; //list of students //inial valued constructor public Instructor(String n, Student s[]) { name=n; list=s; } //get methods public Student[] getStudent() { return list; } // returns all the students of an instructor }

---------------------------------------

public class Test { public static void main(String[] args) { int g1[]={90,89,40,70}; int g2[]={100,90,80,70,100}; int g3[]={89,95,80,70}; int g4[]={99,79,80,60}; int g5[]={100,100,80,90,100}; int g6[]={100,50,80,95,100}; Course list1[]=new Course[4]; list1[0]=new Course("Programming 1", 180,g1); list1[1]=new Course("History", 120, g2); list1[2]=new Course("Mathematics", 136,g3); list1[3]=new Course("Data Mining", 251,g4); Course list2[]=new Course[2]; list2[0]=new Course("Art", 104,g5); list2[1]=new Course("Music", 100,g6); Student L[]=new Student[2]; L[0]=new Student("Sara", list1); L[1]=new Student("Mike",list2); Instructor A=new Instructor("James Gary",L); } }

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

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago