TK Study

Multiple choice › Algorithms (validation)

Algorithms (validation)

1. Algorithms (validation)

A program requires the user to enter the number of tickets to be purchased. This must be an integer from 1 to 10 inclusive. Which algorithm should be used to validate the entered data?

  1. Get NumTick WHILE NumTick <1 AND NumTick >10 Display “Please enter a valid number of tickets” Get NumTick ENDWHILE ProcessPurchase
  2. Get NumTick REPEAT Display “Please enter a valid number of tickets” UNTIL NumTick > 0 AND NumTick < 10 ProcessPurchase
  3. Get NumTick IF NumTick <1 OR NumTick > 10 Display “Please enter a valid number of tickets” ENDIF ProcessPurchase
  4. Get NumTick WHILE NumTick <1 OR NumTick >10 Display “Please enter a valid number of tickets” Get NumTick ENDWHILE ProcessPurchase
Answer

D

NESA answer key: D. Old syllabus (SDD): useful as overlap practice only.