Writing your answer
Once you鈥檝e thought about how you鈥檒l meet each individual requirement, you need to write the answer in pseudocode Also written as pseudo-code. A method of writing up a set of instructions for a computer program using plain English. This is a good way of planning a program before coding.. Remember, you can add comments to pseudo-code by putting a # at the start of the comment. Comments in pseudo-code questions enable you to explain things that aren鈥檛 obvious to the examiner.
SET looping TO TRUE聽聽聽聽聽#used to keep the loop running until the user wants to quit
WHILE looping = TRUE DO聽聽聽聽聽#loop to keep asking for identifiers
聽聽聽聽聽#get identifier from user
聽聽聽聽聽RECEIVE identifier FROM (STRING) KEYBOARD
聽聽聽聽聽IF identifier = 鈥楺鈥 THEN聽聽聽聽聽#user wants to quit
聽聽聽聽聽聽聽聽聽聽SET looping TO FALSE聽聽聽聽聽#loop won鈥檛 run again as condition will be false
聽聽聽聽聽聽聽聽聽聽SEND 鈥楤ye鈥 TO DISPLAY
听听听听听贰尝厂贰 IF LENGTH (identifier) <> 9 THEN
聽聽聽聽聽聽聽聽聽聽SEND 鈥楾he customer identifier is not nine characters long鈥 TO DISPLAY
听听听听听贰尝厂贰
聽聽聽聽聽聽聽聽聽聽#check last 3 characters
聽聽聽聽聽聽聽聽聽聽SET badAlpha TO FALSE #this is a flag that will be changed to TRUE if a non-uppercase letter is found
聽聽聽聽聽聽聽聽聽聽FOR count FROM 6 TO 8 DO
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽IF (NOT (identifier[count] >= 鈥楢鈥 AND identifier[count] <= 鈥榋鈥)) THEN
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SEND 鈥楤ad character in last 3 characters found鈥 TO DISPLAY
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SET badAlpha TO TRUE
聽聽聽聽聽聽聽聽聽聽END IF
聽聽聽聽聽END FOR
聽聽聽聽聽IF badAlpha = FALSE THEN
聽聽聽聽聽聽聽聽聽聽SEND 鈥楩inal three characters are valid鈥 TO DISPLAY
聽聽聽聽聽END IF
END IF
It is important to use easy-to-understand identifierA name given to a part of a program, such as a variable, constant, function, procedure or module. names and use indentation correctly as this will make the pseudo-code easier to read and help you gain maximum marks.