Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

nCourse getFinalGrade() get final grade based on homeworks and exams 20% for each homework and 30% for each exam import java.util.ArrayList; //class Course class Course

nCourse

getFinalGrade() get final grade based on homeworks and exams

20% for each homework and 30% for each exam

import java.util.ArrayList;

//class Course class Course { public String name; //Name of the course public double homework1; //Grade of homework 1 public double homework2; //Grade of homework 2 public double midterm; //Grade of midterm exam public double finalexam; //Grade of final exam

public Course(String name, double hw1, double hw2, double mid, double fin) { this.name = name; homework1 = hw1; homework2 = hw2; midterm = mid; finalexam = fin; }

//Final grade public double FinalGrade() { //Implement your codes here //Final grade is computed by 20% for each homework, 30% for each exam //change return 0.0 to what you need to return return 0.0; } }

//Class Student public class Student { public String name; //Student's name public ArrayList courses = new ArrayList<>(); //Student's courses

public Course getMaxGrade() { //The course in array courses which has the maximum Final Grade //Implement your codes here //change null to what you need to return return null; }

public Course getMinGrade() { //The course in array courses which has the minimum Final Grade //Implement your codes here //change null to what you need to return return null; }

public double getAvgGrade() { //Return the average final grade of all courses of one student //Implement your codes here //change nil to what you need to return return 0.0; }

public static double getStudentAvgFrom(ArrayList s, String coursename) { return 0.0; }

public static double getStudentAvgFrom(ArrayList s) { return 0.0; }

//Don't change the following codes public static void main(String args[]) { //A list of students ArrayList students = new ArrayList<>();

//Information of the first student Student student1 = new Student(); student1.name = "Peter"; student1.courses.add(new Course("Physics",88, 77,84, 83)); student1.courses.add(new Course("Math", 92, 93, 90, 96)); student1.courses.add(new Course("Mobile Computing",96, 94, 93, 99)); students.add(student1); //Add one student to the list

//Information of the second student Student student2 = new Student(); student2.name = "Alice"; student2.courses.add(new Course( "Physics", 92, 86, 83, 93)); student2.courses.add(new Course("Math", 91, 88, 87, 96)); student2.courses.add(new Course("Mobile Computing", 91, 93, 88, 90)); students.add(student2);

//Information of the third student Student student3 = new Student(); student3.name = "Bob"; student3.courses.add(new Course( "Physics", 66, 78, 75, 84)); student3.courses.add(new Course( "Math", 81, 82, 86, 88)); student3.courses.add(new Course( "Mobile Computing", 97, 96, 91, 99)); students.add(student3);

System.out.printf("Total: %d students ", students.size()); System.out.printf("%s's Physics final grade is %f ",student1.name, student1.courses.get(0).FinalGrade()); if(student1.getMaxGrade()!=null) { System.out.printf("%s is the best course of %s, and its grade is %f ",student1.getMaxGrade().name,student1.name,student1.getMaxGrade().FinalGrade()); } else { System.out.printf("Errors occured when getting %s best course.",student1.name); } if(student1.getMinGrade()!=null) { System.out.printf("%s is the worse course of %s, and its grade is %f ", student1.getMinGrade().name, student1.name, student1.getMinGrade().FinalGrade()); }else { System.out.printf("Errors occured when getting %s worse course.",student1.name); }

System.out.printf("The average final grade of %s is %f ",student1.name,student1.getAvgGrade());

System.out.printf("Bonus 1: The average grade of Physics of all students is %f ", Student.getStudentAvgFrom(students,"Physics")); System.out.printf("Bonus 2: The average grade all courses of all students is %f", Student.getStudentAvgFrom(students)); } }

nStudent

getMaxGrade(): get the course with highest grade

getMinGrade(): get the course with lowest grade

getAvgGrade(): get the average grade for all course

nBonus Question:

getStudentAvgbyCourse(): get the average grade for a course from given students

getStudentAvgTotal(): get the average grade for all course from given students

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxiv Special Issue On Database And Expert Systems Applications Lncs 9510

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Hendrik Decker ,Lenka Lhotska ,Sebastian Link

1st Edition

366249213X, 978-3662492130

More Books

Students also viewed these Databases questions

Question

1.The difference between climate and weather?

Answered: 1 week ago

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago