Table of contents | |
Introduction | |
Validation | |
Range Checks | |
Verification |
OUTPUT “Enter a number between 0 and 100”
REPEAT
INPUT Number
IF Number < 0 OR Number > 100
THEN
OUTPUT “Number is not between 0 and 100, please try again”
ENDIF
UNTIL Number >= 0 AND Number <= 100
OUTPUT “Please enter your 4 digit bank PIN number”
REPEAT
INPUT Pin
IF LENGTH(Pin) <> 4
THEN
OUTPUT “Your pin number must be four characters in length, please try again”
ENDIF
UNTIL LENGTH(Pin) = 4
OUTPUT “Please enter a password between 8 and 20 characters”
REPEAT
INPUT Password
IF LENGTH(Password) < 8 OR LENGTH(Password) > 20
THEN
OUTPUT “Your password must be between 8 and 20 characters in length, please try again”
ENDIF
UNTIL LENGTH(Password) >= 8 AND LENGTH(Password) <= 20
OUTPUT “Enter an integer number”
REPEAT
INPUT Number
IF Number <> DIV(Number, 1)
THEN
OUTPUT “Not a whole number, please try again”
ENDIF
UNTIL Number = DIV(Number , 1)
OUTPUT “Enter your username”
REPEAT
INPUT Username
IF Username = “”
THEN
OUTPUT “No username entered, please try again”
ENDIF
UNTIL Username <> “”
INPUT IDNumber
IF LENGTH(IDNumber) <> 6
THEN
OUTPUT “ID number must be 6 characters long”
END IF
ValidChars ← “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
FirstChar ← SUBSTRING(IDNumber, 1, 1)
ValidChar ← False
Index ← 1
WHILE Index <= LENGTH(ValidChars) AND ValidChar = False DO
IF FirstChar = ValidChars[Index]
THEN
ValidChar ← True
ENDIF
Index ← Index + 1
ENDWHILE
IF ValidChar = False
THEN
OUTPUT “First character is not a valid uppercase alphabetical character”
ENDIF
SecondChar ← SUBSTRING(IDNumber, 2, 2)
ValidChar ← False
Index ← 1
WHILE Index <= LENGTH(ValidChars) AND ValidChar = False DO
IF SecondChar = ValidChars[Index]
THEN
ValidChar ← True
ENDIF
Index ← Index + 1
ENDWHILE
IF ValidChar = False
THEN
OUTPUT “Second character is not a valid uppercase alphabetical character”
ENDIF
Digits ← INT(SUBSTRING(IDNumber, 3, 6))
IF Digits < 0000 OR Digits > 9999
THEN
OUTPUT “Digits invalid. Enter four valid digits in the range 0000-9999”
ENDIF
Barcode ← “9780201379624”
Total ← 0
FOR Index = 1 to LENGTH(Barcode) - 1
IF Index MOD 2 = 0
THEN
Total ← Total + CAST_TO_INT(Barcode[Index])*3
ELSE
Total ← Total + CAST_TO_INT(Barcode[Index])*1
ENDIF
NEXT Index
CheckDigit ← 10 - Total MOD 10
IF CheckDigit = Barcode[LENGTH(Barcode)]
THEN
OUTPUT “Valid check digit”
ELSE
OUTPUT “Invalid check digit”
ENDIF
REPEAT
OUTPUT “Enter your password”
INPUT Password
OUTPUT “Please confirm your password”
INPUT ConfirmPassword
IF Password <> ConfirmPassword
THEN
OUTPUT “Passwords do not match, please try again”
ENDIF
UNTIL Password = ConfirmPassword
REPEAT
OUTPUT “Enter your name”
INPUT Name
OUTPUT “Your name is: “, Name, “. Is this correct? (y/n)”
INPUT Answer
UNTIL Answer = “y”
92 docs|30 tests
|
1. What are validation checks in CIE IGCSE Computer Science? |
2. How do conditional statements help in validation in CIE IGCSE Computer Science? |
3. Why is ensuring password security important in CIE IGCSE Computer Science? |
4. How does understanding data validation help in algorithm development in CIE IGCSE Computer Science? |
5. What are some common format checks and identification methods used in validation in CIE IGCSE Computer Science? |
|
Explore Courses for Year 11 exam
|