A lecturer makes use of a list to store the scores of a test similar to the following: var scores = [45,50,89,90,46,67] Each element in the list represents the score obtained by student i, where i is the respective index. To help the lecturer perform some operations, you are required to write and test the following functions Function called captureScores This function accepts an integer representing the number of students in the class e.g. 5 It then captures the scores for the 5 students, one by one, adding them to a list of integers Finally, it returns the list once all n scores have been captured. Hint – Make use of a loop. Start with an empty list, use the add() method to populate your list with scores, one by one as they are captured. Function called printResults that takes a list of integers as an argument ( e.g. list scores) and prints the result for each score using the following grading scheme Score Result 0 – 44 Fail 45 – 49 Supp 50 – 79 Pass 80 – 100 Distinction Function called findHighest that takes a list of integers as an argument ( e.g. list scores) and returns the maximum value in the list. Function called findLowest that takes a list of integers as an argument ( e.g. list scores) and returns the minimum value in the list. Function called getSum that takes a list of integers as an argument ( e.g. list scores) and returns the sum of all the values in the list. Function called getAverage that takes a list of integers as an argument ( e.g. list scores) and returns the average score of all the values in the list. Average = sum/number of students. Function called getPassRate that takes a list of integers as an argument ( e.g. list scores) and an integer representing the pass mark and returns the pass rate as a percentage. Pass Rate = (Number of Students with a score >= pass mark / Total Number of Students)*100. Function called printMenu that prints a menu showing the following operations that correspond to each of the operations mentioned above Score Manager Capture Scores Print Results Find Highest Score Find Lowest Score Get the Sum of Scores Get Average Score Get Pass Rate Exit method main() Make use of the functions you wrote above to implement a simple score management system that presents the user with the Menu above (see 8), and allows the user to repeatedly carry out any of the desired operations ( 1…7, and only terminates the program when option 8 (Exit) is chosen.
A lecturer makes use of a list to store the scores of a test similar to the following:
var scores = [45,50,89,90,46,67]
Each element in the list represents the score obtained by student i, where i is the respective index.
To help the lecturer perform some operations, you are required to write and test the following functions
- Function called captureScores
- This function accepts an integer representing the number of students in the class e.g. 5
- It then captures the scores for the 5 students, one by one, adding them to a list of integers
- Finally, it returns the list once all n scores have been captured.
Hint – Make use of a loop. Start with an empty list, use the add() method to populate your list with scores, one by one as they are captured.
- Function called printResults that takes a list of integers as an argument ( e.g. list scores) and
prints the result for each score using the following grading scheme
Score Result
0 – 44 Fail
45 – 49 Supp
50 – 79 Pass
80 – 100 Distinction
- Function called findHighest that takes a list of integers as an argument ( e.g. list scores) and returns the maximum value in the list.
- Function called findLowest that takes a list of integers as an argument ( e.g. list scores) and returns the minimum value in the list.
- Function called getSum that takes a list of integers as an argument ( e.g. list scores) and returns the sum of all the values in the list.
- Function called getAverage that takes a list of integers as an argument ( e.g. list scores) and returns the average score of all the values in the list. Average = sum/number of students.
- Function called getPassRate that takes a list of integers as an argument ( e.g. list scores) and an integer representing the pass mark and returns the pass rate as a percentage.
Pass Rate = (Number of Students with a score >= pass mark / Total Number of Students)*100.
- Function called printMenu that prints a menu showing the following operations that correspond to each of the operations mentioned above
Score Manager
- Capture Scores
- Print Results
- Find Highest Score
- Find Lowest Score
- Get the Sum of Scores
- Get Average Score
- Get Pass Rate
- Exit
- method main()
Make use of the functions you wrote above to implement a simple score management system that presents the user with the Menu above (see 8), and allows the user to repeatedly carry out any of the desired operations ( 1…7, and only terminates the program when option 8 (Exit) is chosen.
Step by step
Solved in 3 steps with 14 images