Download presentation
Presentation is loading. Please wait.
Published byShanna Davidson Modified over 5 years ago
1
Learning Intention I will learn about the standard algorithm for input validation.
2
Analysis Design Implementation Testing Documentation Evaluation
3
Standard Algorithms An algorithm is a step-by-step procedure for solving a problem in a finite number of steps. Any bit of written code that carries out a specific task could be said to be an algorithm.
4
A program to add two test marks together is to be created
A program to add two test marks together is to be created. Both tests are marked out of 20. Normal Test Data: Extreme Test Data: Exceptional Test Data: 1 -> 19 0, 20 -1, 21
5
A program to add two test marks together is to be created
A program to add two test marks together is to be created. Both tests are marked out of 20.
6
Standard Algorithm - Input Validation
Input validation is used to check that input to the program is acceptable. Validating input is a specific task that is used in lots of programs so it is called a standard algorithm.
7
Input Validation Example
A program to enter a users age: SEND “Enter an age (range )” TO DISPLAY RECEIVE age FROM (INTEGER) KEYBOARD SEND “You are “ & age & “ years old” TO DISPLAY
8
Input Validation – Example 1
SEND “Enter an age (range )” TO DISPLAY RECEIVE age FROM (INTEGER) KEYBOARD WHILE age ˂ 0 OR age ˃ 130 DO SEND “Invalid. Try again” TO DISPLAY END WHILE SEND “You are “ & age & “ years old” TO DISPLAY
9
Input Validation – Example 2
REPEAT SEND “Enter an age (range )” TO DISPLAY RECEIVE age FROM (INTEGER) KEYBOARD IF age < 0 OR age > 130 THEN SEND “Invalid. Try again” TO DISPLAY END IF UNTIL age >= 0 AND age <= 130 SEND “You are “ & age & “ years old” TO DISPLAY
10
Standard Algorithm - Input Validation
Input validation can be added to any program that is accepting input, even inside another loop (fixed or conditional).
11
What did this program do?
SET total TO 0 REPEAT RECEIVE number FROM KEYBOARD SET total TO total + number SEND total TO DISPLAY UNTIL total > 100
12
Over 100 (with each number <= 20)
SET total TO 0 REPEAT RECEIVE number FROM KEYBOARD IF number > 20 THEN SEND “number too big” TO DISPLAY END IF UNTIL number <= 20 SET total TO total + number SEND total TO DISPLAY UNTIL total > 100
13
Programming Tasks Complete the programming tasks on pages 73-75
Extension Sets 6 & 6b
14
Success Criteria I can create an input validation algorithm using a conditional loop.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.