Quiz7-InputValidation Flashcards
An input validation loop is sometimes called an ERROR HANDLER(T/F)
True
If a user is asked to enter the number of widgets he or she wants to buy and enters “two”, the program will automatically change the entry to an integer(T/F)
False
If a user is asked to enter the number of widgets he or she wants to buy, the iSINTEGER function can be used to validate this input.(T/F)
True
Programs should be designed to inspect all input before processing that input.(T.F)
True
A priming read is needed when a pretest loop is executed.(T/F)
True
A Boolean function can often be used to validate data(T/F)
True
The most difficult input error to validate is an empty read.(T/F)
False
Defensive programming is the practice of anticipating errors that can happen while a program is running and designing the program to catch and deal with those errors.(T/F)
True
Checking for the accuracy of data, even when the user provides valid input, is part of input validation. (T/F)
True
Checking that input data is reasonable is programmatically impossible.(T/F)
False
Input validation is not needed if the program is well designed.(T/F)
False
A programmer is not permitted to use library functions for input validation.(T/F)
False
What do computer programmers say about the fact that computers can’t tell the difference between good and bad data?
Garbage in, Garbage out
The purpose of _____________ is to get the first input value for the validation of a loop.
The priming read
Designing a program to avoid common errors is called ____________ programming.
defensive
Input ___________ is commonly done with a loop that iterates as long as an input variable contains bad data.
validation
A(n) ___________ is another term for input validation.
Error Trap
The priming read is placed __________ the loop.
Before
If the user, when asked for his/her date of birth, enters a date in the future, this error should be caught by a ____________ check.
A) date
B) time
C) reasonableness
C) reasonableness
Accepting February 29 for input only in a leap year is a check that should be caught by a ____________ check.
A) date
B) time
C) reasonableness
A) date
Which function could be used to validate an entry for a user’s chosen name that must be between 4 and 12 characters?
legnth
Which function could be used to validate that the correct data type was input for an amount of money?
A) isReal
B) isString
C) Legnth
A) isReal
Which function could be used to simplify the process of string validation?
A) isReal
B) isString
C) toLower
toLower
What would display if the following statements are coded and executed and the user enters 3 twice at the prompts?
Display “Enter your age:”
Input age
Do
Display “Impossible! Enter an age greater than 0:”
Input age
While age <=0
Display “Thank you”
A) Impossible! Enter an age greater than 0:
B) Thank you.
Impossible! Enter an age greater than 0:
C) Impossible! Enter an age greater than 0:
Thank you.
C) Impossible! Enter an age greater than 0:
Thank you.
What would display if the following statements are coded and executed and the user enters -3 at the first prompt, - at the next prompt, and 22 at the third prompt?
Display “Enter your age:”
Input age
While age <=0
Display “Impossible! Enter an age greater than 0:”
Input age
End While
Display “Thank you.”
A) Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:
Thank you.
B) Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:
C) Thank you.
A) Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:
Thank you.
What is wrong with the following pseudocode that validates a user’s entry?
Display “Do you want to play again? Enter y or n.”
While toLower(choice) != “y” AND toLower (choice) != “n”
Display “Please answer y or n. Play again?”
Input choice
End While
A) There is no check for uppercase Y or N
B) There is no priming read
C) The Boolean expression should be an OR, not AND
B) There is no priming read