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.

Khalid Khan
CMSC 501
Assign # 4
num scores[SIZE]
num x
num y
num temp
num total
num COMPS = SIZE - 1
fillArray()
sortArray()
displayTotal()
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

Khalid Khan
CMSC 501
Assign # 4
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.

Khalid Khan
CMSC 501
Assign # 4
num median
num COMPS = SIZE - 1
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()

Khalid Khan
CMSC 501
Assign # 4
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