using only loops, i need to figure out how to generate multiple random numbers but i don't know how and also how i would discard numbers that are lower than 40
Write a method double calcAverageScore(int num) that takes a positive integer number to indicate how many scores do you need. Then generate that many random scores in range [0, 100]. And then calculate the average of the scores. When you calculate the average, if a score is lower than 40, then it will not be used.
For example: if num equals 3, this will generate 3 scores, and assume the scores are: 85, 12, 77. Then the algorithm will discard 12 since it is lower than 40, and the only calculate the average of the other two. (85 + 77) / 2 = 81.
Aucun commentaire:
Enregistrer un commentaire