Showing posts with label Pseudo_Code. Show all posts
Showing posts with label Pseudo_Code. Show all posts

Tuesday, March 22, 2011

Sudo Code - Working out Highest mark P1-J10-Q9b

PROCEDURE PRIZE                             Always Name the Procedure
OPEN FILE STUDENTS                        It says there's a File
SEARCH FOR FORM                             It only says it wants one Form done
SET HIGH = 0
WHILE NOT END OF STUDENTS, 
      DO CALL PROCEDURE MEAN     Start the loop by running the MEAN procedure
              IF AVERAGE > HIGH THEN    Check to see if the MEAN is the highest so far
                     HIGH = AVERAGE; STUDENT = CURRENT NAME; Save Mark as HIGH and Name
                     FLAG = FALSE 
             ELSE IF AVERAGE = HIGH THEN 
                    FLAG = TRUE                       They've used the FLAG variable to see if there's a draw
              ENDIF
ENDWHILE 
IF FLAG = TRUE THEN 
REPORT ‘Problem Equal high scorers’                        Report a draw or
ELSE OPEN FILE ‘PRIZES’                                           Open PRIZES file
COPY FORM AND STUDENT TO PRIZES ENDIF    Save the result (Mark & Name)
END

Pseudo Code - Work out an average P1-J10-Q9a

Calculate an average in 4 Marks
Procedure Mean                            1
Total = 0
Count = 0                                        1
DoWhile there's still marks          1
Get Mark
Count = Count + 1                         Running Total
Total = Total + Mark                      Running Total
EndWhile
Average = Total / Count               1       After all the looping
End Mean