(* Programmer: Scott Langley *) (* Student Number: 541-88-9657 *) (* Class: CS 211, sec.1 *) (* Instructor: Sue-May Jin *) (* Date: 5/25/88 *) (* *) (* This program analyzes the results of a true-false exam from a file *) (* called 'data6'. For each of twenty students, their student i.d. numbers *) (* and their answers are read in. The answers are in a string which is *) (* compared to a string of the answer key. One point is given for each *) (* answer matching the key. Then letter grades are calculated based on the *) (* score. After each student is processed, the students are sorted by score *) (* from highest to lowest. The sort is a bubble sort and an index array is *) (* used to avoid gross switching with the seperate arrays. Finally, a table *) (* is printed of the student numbers, scores, and grades in the descending *) (* order in which they were sorted. *) program assignment6; type number=array[1..20] of integer; onechar=array[1..20] of char; fourchar=array[1..20] of string[4]; tenchar=array[1..20] of string[10]; var idnumber:fourchar; answers:tenchar; score:number; grade:onechar; index:number; x:integer; f:text; procedure process_student; (* procedure reads in the student number and answer list for each student *) (* and compares the answers with the key to determine the score, and then *) (* computes the grade. *) const key='0100101101'; var y:integer; begin readln(f,idnumber[x]); readln(f,answers[x]); score[x]:=0; for y:=1 to 10 do if (copy(answers[x],y,1)=copy(key,y,1)) then score[x]:= score[x] + 1; case score[x] of 10,9:grade[x]:= 'A'; 8,7 :grade[x]:= 'B'; 6,5 :grade[x]:= 'C'; else grade[x]:= 'F'; end; end; procedure bubblesort(var A:number; size:integer); (* this is the standard bubblesort the gave us, modified for this program *) var current,last:integer; procedure switch(var first,second:integer); (* procedure to switch array places, uses index array *) var temporary:integer; begin temporary := first; first := second; second := temporary; end; begin for current:= 1 to 20 do index[current]:=current; for last:=size downto 2 do for current:= 1 to last-1 do if A[index[current]]