Programming Logic and Design
Chapter 3 Review Questions Complete
Answers
Which of the lettered choices is equivalent to the following decision?
if x > 10 then
if y > 10 then
print "X"
endif
endif
a. if x > 10 AND y > 10 then print "X"
b. if x > 10 OR y > 10 then print "X"
c. if x > 10 AND x > y then print "X"
d.if y > x then print "X" - ANSWER-if x > 10 then
The Acme Computer Company operates in all 50 of the United States. The Midwest
Sales region consists of five states--Illinois, Indiana, Iowa, Missouri, and Wisconsin.
Suppose that you have input records containing Acme customer data, including state
of residence. To most efficiently select and display all customers who live in the
Midwest Sales region, you would use ___________.
a. five completely separate unnested if statements
b. nested if statements using AND logic
c. nested if statements using OR logic
d.Not enough information is given. - ANSWER-c. nested if statements using OR logic
The Midwest Sales region of Acme Computer Company consists of five states—
Illinois, Indiana, Iowa, Missouri, and Wisconsin. About 50 percent of the regional
customers reside in Illinois, 20 percent in Indiana, and 10 percent in each of the
other three states. Suppose you have input records containing Acme customer data,
including state of residence. To most efficiently select and display all customers who
live in the Midwest Sales region, you would ask first about residency in
_____________.
a. Illinois
b. Indiana
c. Either Iowa, Missouri, or Wisconsin--It does not matter which one of these three
are first
d. Any of the five states; it does not matter which one is first - ANSWER-a. Illinois
The Boffo Balloon Company makes helium balloons. Large balloons cost $13 a
dozen, medium-sized balloons cost $11 a dozen, and small balloons cost $8.60 a
dozen. About 60 percent of the company's sales are the smallest balloons, 30
, percent are the medium, and large balloons constitute only 10 percent of sales.
Customer order records include customer information, quantity ordered, and size.
When you write a program to determine price based on size, for the most efficient
decision, you should ask first whether the size is _____________.
a. large
b. medium
c. small
d. It does not matter. - ANSWER-c. small
The Boffo Balloon Company makes helium balloons in three sizes, 12 colors, and
with a choice of 40 imprinted sayings. As a promotion, the company is offering a 25
percent discount on orders of large, red "Happy Valentine's Day" balloons. To most
efficiently select the orders to which a discount applies, you would use
_____________.
a. three completely separate unnested if statements
b. nested if statements using AND logic
c. nested if statements using OR logic
d. Not enough information is given. - ANSWER-b. nested if statements using AND
logic
Radio station FM-99 keeps a record of every song played on the air in a week. Each
record contains the day, hour, and minute the song started, and the title and artist of
the song. The station manager wants a list of every title played during the important
8 a.m. commute hour on the two busiest traffic days, Monday and Friday. Which
logic would select the correct titles?
a. if day = "Monday" OR day = "Friday" OR hour = 8 then
print title
endif
b. if day = "Monday" then
if hour = 8 then
print title
else
if day = "Friday" then
print title
endif
endif
endif
c. if hour = 8 AND day = "Monday" OR day = "Friday" then
print title
endif
d. if hour = 8 then
if day = "Monday" OR day = "Friday" then
print title
endif
Chapter 3 Review Questions Complete
Answers
Which of the lettered choices is equivalent to the following decision?
if x > 10 then
if y > 10 then
print "X"
endif
endif
a. if x > 10 AND y > 10 then print "X"
b. if x > 10 OR y > 10 then print "X"
c. if x > 10 AND x > y then print "X"
d.if y > x then print "X" - ANSWER-if x > 10 then
The Acme Computer Company operates in all 50 of the United States. The Midwest
Sales region consists of five states--Illinois, Indiana, Iowa, Missouri, and Wisconsin.
Suppose that you have input records containing Acme customer data, including state
of residence. To most efficiently select and display all customers who live in the
Midwest Sales region, you would use ___________.
a. five completely separate unnested if statements
b. nested if statements using AND logic
c. nested if statements using OR logic
d.Not enough information is given. - ANSWER-c. nested if statements using OR logic
The Midwest Sales region of Acme Computer Company consists of five states—
Illinois, Indiana, Iowa, Missouri, and Wisconsin. About 50 percent of the regional
customers reside in Illinois, 20 percent in Indiana, and 10 percent in each of the
other three states. Suppose you have input records containing Acme customer data,
including state of residence. To most efficiently select and display all customers who
live in the Midwest Sales region, you would ask first about residency in
_____________.
a. Illinois
b. Indiana
c. Either Iowa, Missouri, or Wisconsin--It does not matter which one of these three
are first
d. Any of the five states; it does not matter which one is first - ANSWER-a. Illinois
The Boffo Balloon Company makes helium balloons. Large balloons cost $13 a
dozen, medium-sized balloons cost $11 a dozen, and small balloons cost $8.60 a
dozen. About 60 percent of the company's sales are the smallest balloons, 30
, percent are the medium, and large balloons constitute only 10 percent of sales.
Customer order records include customer information, quantity ordered, and size.
When you write a program to determine price based on size, for the most efficient
decision, you should ask first whether the size is _____________.
a. large
b. medium
c. small
d. It does not matter. - ANSWER-c. small
The Boffo Balloon Company makes helium balloons in three sizes, 12 colors, and
with a choice of 40 imprinted sayings. As a promotion, the company is offering a 25
percent discount on orders of large, red "Happy Valentine's Day" balloons. To most
efficiently select the orders to which a discount applies, you would use
_____________.
a. three completely separate unnested if statements
b. nested if statements using AND logic
c. nested if statements using OR logic
d. Not enough information is given. - ANSWER-b. nested if statements using AND
logic
Radio station FM-99 keeps a record of every song played on the air in a week. Each
record contains the day, hour, and minute the song started, and the title and artist of
the song. The station manager wants a list of every title played during the important
8 a.m. commute hour on the two busiest traffic days, Monday and Friday. Which
logic would select the correct titles?
a. if day = "Monday" OR day = "Friday" OR hour = 8 then
print title
endif
b. if day = "Monday" then
if hour = 8 then
print title
else
if day = "Friday" then
print title
endif
endif
endif
c. if hour = 8 AND day = "Monday" OR day = "Friday" then
print title
endif
d. if hour = 8 then
if day = "Monday" OR day = "Friday" then
print title
endif