National 5 – Algorithm Specification (Revision)

Input validation – checking that what is entered by the user is acceptable.

The following program checks that age is a positive number.

1. SEND “Please enter age” TO DISPLAY
3. RECEIVE age FROM (INTEGER) KEYBOARD
4. WHILE age < 0 DO
5.         SEND “re-enter data” TO DISPLAY
6.         RECEIVE age FROM (INTEGER) KEYBOARD
7. END WHILE

Note that acceptable does not mean accurate, just sensible.

Leave a Reply

Your email address will not be published. Required fields are marked *