May/June 2010
Students take exams in all their subjects at the end of every year. A procedure is to be written which inputs the marks of a student from the STUDENT file and calculates the mean mark for that student,
Produce an algorithm which will carry out the above taks. The Procedure is to be called MEAN.
Procedure Mean
NumberofMarks = 0
Total = 0
Do While there are marks
Get Mark
NumberofMarks = NumberofMarks + 1
Total = Total + Mark
End While
Mean = Total/NumberofMarks
End
The school awards a prize each year to the students who achieve the highest mean mark in their form.
Produce an algorithm for a procedure called PRIZE which will determine which student will win the prize for a particular form. The name of the form and the name of the student should then be saved to a file called PRIZES.
Procedure Prize
OPEN FILE STUDENTS
SEARCH FOR FORM
SET HIGH = 0
WHILE NOT END OF STUDENTS, DO
CALL PROCEDURE MEAN
IF AVERAGE > HIGH THEN HIGH = AVERAGE; STUDENT = CURRENT NAME;
FLAG = FALSE
ELSE IF AVERAGE = HIGH THEN FLAG = TRUE
ENDIF
ENDIF
ENDWHILE
IF FLAG = TRUE THEN REPORT ‘Problem Equal high scorers’
ELSE OPEN FILE ‘PRIZES’
COPY FORM AND STUDENT TO PRIZES
END
No comments:
Post a Comment