' chapter 9 example program ' sum and average of n grades ' grades are from 0-100 dim sum as int 'this variable will store the sum of the n grades dim avg as int 'this variable will store the average of the n grades dim n as int ' the number of grades to average print "How many grades?" input n dim grade[n] as int ' an array of n grades ' ---INPUT --- for i=0 to n-1 'get the inputs print "Enter grade ", i ' notice that we indent in loops input grade[i] 'get the grades from the student next '--- PROCESS --- ' compute the sum and the average for i=0 to n-1 if grade[i] >=94 then print grade[i], "=A" elseif grade[i]>=86 then print grade[i],"=B" elseif grade[i]>=78 then print grade[i], "=C" elseif grade[i]>=70 then print grade[i], "=D" else print grade[i], "=F" end if sum = sum + grade[i] 'notice we accumulate the sum next avg = sum/n '--- OUTPUT --- print "The average of your" print n, " grades is ", avg if avg >= 94 then print avg, "=A" elseif avg>=86 then print avg,"=B" elseif avg>=78 then print avg, "=C" elseif avg>=70 then print avg, "=D" else print avg, "=F" end if print "Press to continue" dim tmp as int' a temporary variable input tmp 'wait for the user to press enter