Algorithm Specification

  • Input Validation

Input validation

checking that what is entered by the user is acceptable e.g. that an age isn’t a negative number.

Generic example

1. Repeat
2.   Send “Please enter data” to display
3.   Receive data from keyboard
4.   If data is outwith range then
5.       Send “re-enter data” to display
6. Until data is within range

Checking that Age is between 0 and 120

1. REPEAT
2.    SEND "Please enter your age" TO DISPLAY
3.    RECEIVE age FROM INTEGER KEYBOARD
4.    IF age<0 OR age>120 THEN
5.       SEND "Please input an age between 0 and 120" TO DISPLAY
6. UNTIL age>=0 AND age<=120

Leave a Reply

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