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 task. The procedure is to be called MEAN.
PROCEDURE MEAN
TOTAL = 0
NUMBER = 0
WHILE MARKS STILL LEFT, DO
READ MARK
NUMBER = NUMBER + 1
TOTAL = TOTAL + MARK
ENDWHILE
AVERAGE = TOTAL/NUMBER
Mark Points:
-Naming of MEAN in some way
-Initialise Total and Counter
-Use of WHILE loop with suitable condition
-Increment counter
-Cumulative total
-Calculation of average outside loop
(1 per -, max 4)
Next Question
Mark Points:
-Naming of MEAN in some way
-Initialise Total and Counter
-Use of WHILE loop with suitable condition
-Increment counter
-Cumulative total
-Calculation of average outside loop
(1 per -, max 4)
Next Question
PROCEDURE PRIZE
STUDENT FILE OPEN
MARKHIGHEST = 0
WHILE STUDENTS LEFT, DO
CALL PROCEDURE MEAN
IF STUDENTAVERAGE > MARKHIGHEST
MARKHIGHEST = CURRENTSTUDENTMARK
AND PRIZESTUDENT = CURRENTSTUDENT
EQUALMARK = FALSE
ELSEIF
STUDENTAVERAGE = MARKHIGHEST
THEN EQUALMARK = TRUE
ENDIF
ENDWHILE
IF EQUALMARK = TRUE
THEN SHOW MESSAGE "Highest Mark Equal"
ELSE OPEN PRIZES
COPY MARKHIGHEST AND CURRENTSTUDENT
ENDIF
END
No comments:
Post a Comment