Quiz7-InputValidation Flashcards

1
Q

An input validation loop is sometimes called an ERROR HANDLER(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Programs should be designed to inspect all input before processing that input.(T.F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A priming read is needed when a pretest loop is executed.(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A Boolean function can often be used to validate data(T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The most difficult input error to validate is an empty read.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Checking for the accuracy of data, even when the user provides valid input, is part of input validation. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Checking that input data is reasonable is programmatically impossible.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Input validation is not needed if the program is well designed.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A programmer is not permitted to use library functions for input validation.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What do computer programmers say about the fact that computers can’t tell the difference between good and bad data?

A

Garbage in, Garbage out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The purpose of _____________ is to get the first input value for the validation of a loop.

A

The priming read

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Designing a program to avoid common errors is called ____________ programming.

A

defensive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Input ___________ is commonly done with a loop that iterates as long as an input variable contains bad data.

A

validation

17
Q

A(n) ___________ is another term for input validation.

A

Error Trap

18
Q

The priming read is placed __________ the loop.

A

Before

19
Q

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

A

C) reasonableness

20
Q

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

A) date

21
Q

Which function could be used to validate an entry for a user’s chosen name that must be between 4 and 12 characters?

A

legnth

22
Q

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

A) isReal

23
Q

Which function could be used to simplify the process of string validation?

A) isReal
B) isString
C) toLower

A

toLower

24
Q

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.

A

C) Impossible! Enter an age greater than 0:
Thank you.

25
Q

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

A) Impossible! Enter an age greater than 0:
Impossible! Enter an age greater than 0:
Thank you.

26
Q

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

A

B) There is no priming read