-
Notifications
You must be signed in to change notification settings - Fork 2
W4 VSC Collection Exercises
Nicholas Day edited this page Sep 13, 2022
·
5 revisions
- Continuing from the previous week, create a Module class with attributes (module) name, (module) code. The module name and code should be passed into the constructor.
- In your Course class (from the previous week), add an attribute that is an instance of the ArrayList class. Then in your Course constructor, add four module objects (with module names and codes) to the module ArrayList.
- Now modify the print method of the Course class to output the details of the four modules that are stored in the arraylist.
- Add an attribute to the Student class, which is an integer array (not ArrayList). This array should be created to store four integer marks (with values between 0-100).
- In the constructor of the Student class, assign a mark that will correspond with each module.
- Now amend the print method to print out the module details from the ArrayList, and also print out the mark from the marks array.
- Now write a random number generator that will return a number between 0 and 100. Use this to assign a mark to each of the modules.
- Now write a method in the Module class that will convert a mark to a letter grade. Utilise an appropriate selection code to return the grade that corresponds to the integer mark that is passed in. Output this grade inline with the mark in the print method and check that the correct grade is printed.
- Now rewrite this to use an enumerate type for Grade.
- Extension: Write a ModuleMark class to enable marks to be separated from students and modules. Create a list of students, and then generate marks randomly for each student's four modules.
- Extension: Furthermore, calculate descriptive statistics such as the minimum mark, the maximum mark, and the mean mark and print them to screen. Output the student name and the mark for each of these categories (min, max, mean).