public class Course { private String name; private int capacity; private int enr
ID: 3538334 • Letter: P
Question
public class Course {
private String name;
private int capacity;
private int enroled;
// 1) make an ArrayList of Students called students
ArrayList students = new ArrayList();
/*
2) make a HashSet called prerequisites that contains the course names (String)
students must have completed inorder to be allowed to enroll in this Course.
*/
/*
3) make a HashMap called grades where the keys are String and the values are an array
of type double.
*/
/*
4) make a constuctor that has 3 parameters: a String, an int and a String array
and uses them to set the name of the course, the capacity of the Course and to
fill up the HashSet.
*/
/*
5) make a method called enrol that returns a boolean and has a single parameter of
type Student. It should add the Student to the class only if there is an available
place and the Student has attained a minimum of a C on the prerequisite courses.
*/
/*
6) make a method called withdraw that returns a boolean and has no parameters. If the
Student the is not enroled return false, othewise remove the Student from the Course.
*/
/*
7) make a toString method to return a String that contains a numbered list of each
Student object info in the class
*/
/*
8) make a method called enterGrades that prompts the user with the Student names one by
one in turn, waiting at each step to read from the user 3 scores of type double
(the quiz grades) working out the average and then saving the Student name (the key)
and the array of size 4 (the value) into the grades HashMap.
*/
/*
9) make a method called printOut that prints out a numbered ranking of the Students in
descending order of their average grades.
Hint:
1/ make 2 new ArrayLists of type String and fill up the first one with the Student names
2/ find the Student name with the highest average
3/ add this name to the second ArrayList and remove from the first
4/ keep repeating steps 2 and 3, until the first ArrayList is empty.
5/ print out the second ArrayList
*/
}
Explanation / Answer
answer is simple
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.