# 2 a professor zak allows students to drop the two

• Homework Help
• 16
• 100% (16) 16 out of 16 people found this document helpful

This preview shows page 11 - 16 out of 16 pages.

2. a. Professor Zak allows students to drop the two lowest scores on the ten 100-point quizzes she gives during the semester. Design an application that accepts a student name and 10 quiz scores. Output the student’s name and total points for the student’s eight highest-scoring quizzes.
output “Enter a quiz score” input scores[x] x = x + 1 endwhile return sortArray() x = 0 y = 0 while y < COMPS x = 0 while x < COMPS if scores[x] > scores[x + 1] then swap() endif x = x + 1 endwhile y = y + 1 endwhile return swap() temp = scores[x+1] scores[x+1] = scores[x] scores[x] = temp return
displayTotal() x = 0 total = 0 while x < MAX total = total + scores[x] x = x + 1 endwhile output name, total return B. Modify the application in Exercise 2a so that the student’s mean and median scores on the eight best quizzes are displayed
fillArray() sortArray() displayMeanMedian() stop fillArray() output “Enter the student’s name ” input name x = 0 while x < SIZE output “Enter a quiz score ” input scores[x] x = x + 1 endwhile return sortArray() x = 0 y = 0 while y < COMPS x = 0 while x < COMPS if scores[x] > scores[x + 1] then swap() endif x = x + 1 endwhile y = y + 1
endwhile return swap() temp = scores[x+1] scores[x+1] = scores[x] scores[x] = temp return calcMean() x = 0 total = 0 while x < MAX total = total + scores[x] x = x + 1 endwhile mean = total / MAX return calcMedian() if MAX mod 2 = 0 then median = (scores[MAX/2] + scores[(MAX/2) – 1]) / 2 else median = scores[MAX/2] endif return displayMeanMedian() calcMean() calcMedian()
output name, mean, median return
• • • 