Professional Documents
Culture Documents
Starting Out With Programming Logic and Design 3rd Edition Tony Gaddis Test Bank
Starting Out With Programming Logic and Design 3rd Edition Tony Gaddis Test Bank
Chapter Seven
MULTIPLE CHOICE
1. What is the famous saying among computer programmers that refers to the fact that computers
cannot tell the difference between good and bad data?
a. Garbage input, garbage output
b. Garbage in, garbage out
c. Garbage output is from garbage inputted
d. Garbage out is from garbage in
e. None of the above
ANS: B
2. The purpose of the __________ is to get the first input value for the validation of a loop.
a. GIGO
b. Read
c. Priming read
d. Write
e. None of the above
ANS: C
ANS: A
4. _______________ happens when an input operation attempts to read data, but there is no data
to read.
a. No data
b. Error reading
c. Input error
d. Empty input
e. None of the above
ANS: D
5. Input ______________ is commonly done with a loop that iterates as long as an input variable
contains bad data.
a. Check
b. Validation
c. Examination
d. Priming
e. None of the above
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Gaddis: Starting Out with Programming Logic & Design Test Bank Chapter Seven 2
ANS: B
ANS: B
7. In addition to using loops to validate data, _____________ can also be used to validate data.
a. String Function
b. Real Function
c. Integer Function
d. Boolean Function
e. None of the above
ANS: D
ANS: D
ANS: D
10. What is the first step to use in detecting data type mismatch errors?
a. Read the input as a string
b. Convert to the desired data type
c. Determine whether it can be converted
d. Display error message
e. None of the above
ANS: A
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Gaddis: Starting Out with Programming Logic & Design Test Bank Chapter Seven 3
c. Below
d. Inside and before
e. Inside and below
ANS: B
12. Which of the following statements is true about this Boolean expression?
score < 0 AND score > 100
a. This expression is true for numbers between 0 and 100.
b. This expression is true for numbers greater than 100.
c. This expression is true for numbers less than 0.
d. This expression would never be true.
e. None of the above
ANS: D
13. What type of function can be used to see if the password entered has the minimum number of
characters?
a. Mathematical
b. Boolean
c. String
d. Trigonometric
e. None of the above
ANS: C
14. If, when asked for a date of birth, the user enters a future date, this error should be caught by a
____________ check.
a. Date
b. Time
c. Day
d. Reasonableness
e. None of the above
ANS: D
15. Accepting February 29 in only a leap year is a check that is done by a ___________ check.
a. Date
b. Day
c. Month
d. Calendar
e. None of the above
ANS: A
16. Which of the following library functions could be used to validate the length of a string?
a. random
b. isString
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Gaddis: Starting Out with Programming Logic & Design Test Bank Chapter Seven 4
c. length
d. toUpper
e. None of the above
ANS: C
17. Which of the following library functions could be used to validate that the correct data type was
input for an amount of money?
a. isInteger
b. isString
c. toLower
d. isReal
e. All of the above
ANS: D
18. Which of the following library functions could be used to simplify the process of string
validation?
a. length
b. toUpper
c. isReal
d. isInteger
e. None of the above
ANS: B
TRUE/FALSE
1. True/False: An input validation loop is sometimes called an error handler.
ANS: T
2. True/False: If the user provides bad data as input to a program, the program will correct the
data and produce output.
ANS: F
3. True/False: Programs should be designed such that all input is inspected before it is processed
and bad data is discarded.
ANS: T
ANS: T
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Gaddis: Starting Out with Programming Logic & Design Test Bank Chapter Seven 5
ANS: T
6. True/False: The empty read is not an obvious input error and is a difficult one to handle.
ANS: F
7. True/False: The practice of anticipating errors that can happen while a program is running and
designing the program to avoid those errors is called defensive programming.
ANS: T
8. True/False: Checking for accuracy of data, even when the user provides the right type of data,
is part of input validation.
ANS: T
ANS: F
10. True/False: When using string input validation it is wise to use the library function to convert the
input to upper case or lowercase so case-sensitive string comparisons can be made.
ANS: T
11. True/False: Input validation is not needed if the program is well designed.
ANS: F
12. True/False: Most programming languages do not provide library functions that can be used for
input validation.
ANS: F
ANS: input
2. __________ programming is the practice of anticipating errors that can happen while a program
is running.
ANS: Defensive
3. The acronym ___________ is used by programmers to refer to the fact that computers cannot
tell difference between good and bad data.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Gaddis: Starting Out with Programming Logic & Design Test Bank Chapter Seven 6
ANS: GIGO
4. The input operation that is performed just before a validation loop is known as the _________.
5. The _________________ occurs when the user presses the ENTER key without typing a value
for an input operation.
6. Using a ________________ function many times would simplify the long compound Boolean
expression that is used by a validation loop.
ANS: Boolean
7. To validate if the input data is a valid integer, use the __________ library function.
ANS: isInteger
8. An input validation that accepts strings in mixed case would have incorporated a case-
__________ string comparison operation.
ANS: insensitive
9. The string _________ function plays a role in the string’s validity when a minimum number of
characters are required to be entered.
ANS: length
10. A _________ loop could be used to validate input instead of using the priming read.
ANS: posttest
11. When a payroll program verifies that no value greater than 168 is entered for the number of
hours worked in a week, it is performing a ___________________ check.
12. After the string is read it is determined if it can be converted to the desired data type in a
_____________ error.
13. When a loop rejects any input except the strings “yes” and “no” then it is performing a case-
___________ comparison.
ANS: sensitive
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Another random document with
no related content on Scribd:
ce que j’ai d’étrange et acceptez-moi comme je suis, vous me
rendrez meilleur.
»Si, au contraire de ce que j’espère, Pauline, un motif que
je ne prévois pas, mais qui cependant peut exister, vous
faisait continuer à me fuir comme vous avez essayé de le
faire jusqu’à présent, sachez bien que tout serait inutile:
partout je vous suivrais comme je vous ai suivie; rien ne
m’attache à un lieu plutôt qu’à un autre, tout m’entraîne au
contraire où vous êtes; aller au devant de vous ou marcher
derrière vous sera désormais mon seul but. J’ai perdu bien
des années et risqué cent fois ma vie et mon âme pour arriver
à un résultat qui ne me promettait pas le même bonheur.
»Adieu, Pauline! je ne vous menace pas, je vous implore;
je vous aime, vous m’aimez. Ayez pitié de vous et de moi.»