Deck 3: Making Decisions
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
Play
Full screen (f)
Deck 3: Making Decisions
1
In any Boolean expression,the two values compared can be either variables or ____.
A) numbers
B) nulls
C) constants
D) trivial expressions
A) numbers
B) nulls
C) constants
D) trivial expressions
C
2
In every programming language,addition has precedence over multiplication in an arithmetic statement.
False
3
When you use the OR operator,both of the listed conditions must be met for the resulting
action to take place.
action to take place.
False
4
A ____ is a displayed statement that advises a user what to do.For example,"Please enter your name."
A) start
B) question
C) prompt
D) query
A) start
B) question
C) prompt
D) query
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Every decision you make in a computer program involves evaluating a Boolean expression.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
String value: "BLACK HORSE" is equal to "Black Horse".
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
If X > Y is false,which of the following is always true?
A) X < Y
B) X <= Y
C) X = Y
D) X >= Y
A) X < Y
B) X <= Y
C) X = Y
D) X >= Y
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
A ____ is one that represents only one of two states,true or false.
A) Boolean expression
B) short-circuit evaluation
C) trivial expression
D) truth table
A) Boolean expression
B) short-circuit evaluation
C) trivial expression
D) truth table
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
Boolean (true/false)expressions are named for George Boolean.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
Most programming languages allow you to combine as many AND and OR operators in an expression as you need.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
True/false evaluation is "natural" from a computer's standpoint because computer circuitry consists of two-state on-off switches,often represented by ____.
A) 1 or -1
B) 1 or 0
C) light or dark
D) plus or minus
A) 1 or -1
B) 1 or 0
C) light or dark
D) plus or minus
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
A(n)____ is a value on either side of an operator.
A) operator
B) indicator
C) compound condition
D) operand
A) operator
B) indicator
C) compound condition
D) operand
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
Trivial expressions will always evaluate to the same result.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
The selection structure where the logic can flow only to one of the two alternatives,never to both is called a(n)____ structure.
A) if-then
B) if-then-else
C) loop
D) while
A) if-then
B) if-then-else
C) loop
D) while
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
When new programmers perform range checks,they are prone to using logic that includes too many decisions,entailing more work than is necessary.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
When you use an AND operator to join multiple Boolean expressions,all the individual expressions must be true for the joint expression to be true.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
Comparing two amounts in order to decide if they are not equal to each other is the most confusing of all the comparisons.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
The ____ operator evaluates as true when the left operand is less than or equivalent to the right operand.
A) >=
B) <=
C) >
D) <
A) >=
B) <=
C) >
D) <
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
There are ____ relational comparison operators supported by all modern programming languages.
A) three
B) four
C) five
D) six
A) three
B) four
C) five
D) six
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
Any decision can be made using combinations of just three types of comparisons: _____.
A) equal,more than,and less than
B) equal to,greater than,and less than
C) equal to,more,and less
D) equal,not equal to,and greater than
A) equal,more than,and less than
B) equal to,greater than,and less than
C) equal to,more,and less
D) equal,not equal to,and greater than
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
You use the logical ____ operator to reverse the meaning of a Boolean expression.
A) NOT
B) AND
C) OR
D) XOR
A) NOT
B) AND
C) OR
D) XOR
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
In an OR decision,it is more efficient to first ask the question that is more likely to be ____.
A) greater
B) Boolean
C) false
D) true
A) greater
B) Boolean
C) false
D) true
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
In an AND decision,it is more efficient to first ask the question that is less likely to be ____.
A) larger
B) Boolean
C) false
D) true
A) larger
B) Boolean
C) false
D) true
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
If X is true,Y is true,and Z is false,which of the following expressions is true?
A) X AND Y AND Z
B) X OR Y AND Z
C) X AND Y OR Z
D) X > Y AND Z
A) X AND Y AND Z
B) X OR Y AND Z
C) X AND Y OR Z
D) X > Y AND Z
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
A(n)________ or unreachable path is a logical path that can never be traveled.
A) dead-end
B) dead
C) unstable
D) unattainable
A) dead-end
B) dead
C) unstable
D) unattainable
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
A ____ of values is every value between low and high limits.
A) list
B) block
C) range
D) group
A) list
B) block
C) range
D) group
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
The conditional AND operator in Java,C++,and C# consists of ____.
A) %%
B) &&
C) ||
D) **
A) %%
B) &&
C) ||
D) **
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
In C++,Java,and C#,the ____ is the symbol used for the NOT operator.
A) at-symbol
B) exclamation point
C) underscore
D) tilde
A) at-symbol
B) exclamation point
C) underscore
D) tilde
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
Many programming languages allow you to use ____ to correct your logic when using ANDs and ORs and force the OR expression to be evaluated first.
A) parentheses
B) braces
C) underscores
D) brackets
A) parentheses
B) braces
C) underscores
D) brackets
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
____ are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its parts.
A) Truth diagrams
B) Truth matrix
C) Truth tables
D) Logic diagrams
A) Truth diagrams
B) Truth matrix
C) Truth tables
D) Logic diagrams
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
When several decisions are based on the value of the same variable,many programming languages offer a shortcut called the ____ structure.
A) sequence
B) while
C) loop
D) case
A) sequence
B) while
C) loop
D) case
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
C#,C++,C,and Java use the symbol ____ to represent the logical OR.
A) %%
B) &&
C) ||
D) **
A) %%
B) &&
C) ||
D) **
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following pseudocode selects all people over 21?
A) if age >= 20 then
B) if age > 20 then
C) if age Not < 21 then
D) if age > 21 then
A) if age >= 20 then
B) if age > 20 then
C) if age Not < 21 then
D) if age > 21 then
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
Each part of an expression that uses an AND operator is evaluated only as far as necessary to determine whether the entire expression is true or false,this feature is called ____ evaluation.
A) cut-off
B) once-over
C) first-time
D) short-circuit
A) cut-off
B) once-over
C) first-time
D) short-circuit
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
A series of nested if statements is also called a ____ if statement.
A) connected
B) stacked
C) cascading
D) trailed
A) connected
B) stacked
C) cascading
D) trailed
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
When you combine AND and OR operators,the AND operators take ____,meaning their Boolean values are evaluated first.
A) preference
B) priority
C) precedence
D) residence
A) preference
B) priority
C) precedence
D) residence
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
Sometimes you want to take action when one or the other of two conditions is true,this type of compound condition is called a(n)____ decision.
A) AND
B) OR
C) NOR
D) NOT
A) AND
B) OR
C) NOR
D) NOT
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the lettered choices is equivalent to the following decision? if a > 10 then
If b > 10 then
Output "OK"
Endif
Endif
A) if a > 10 OR b > 10 then output "OK"
B) if a > 10 AND a > b then output "OK"
C) if a > 10 AND b > 10 then output "OK"
D) if a > b then output "OK"
If b > 10 then
Output "OK"
Endif
Endif
A) if a > 10 OR b > 10 then output "OK"
B) if a > 10 AND a > b then output "OK"
C) if a > 10 AND b > 10 then output "OK"
D) if a > b then output "OK"
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
When you use a(n)____ check,you compare a variable to a series of values that mark the limiting ends of ranges.
A) bounds
B) end
C) range
D) truth
A) bounds
B) end
C) range
D) truth
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
A ____ is created when you need to ask multiple questions before an outcome is determined.
A) compound condition
B) compound question
C) truth table
D) trivial expression
A) compound condition
B) compound question
C) truth table
D) trivial expression
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
To most efficiently keep track of the sales for each of the three serving sizes,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) four completely separate unnested if statements
A) three completely separate unnested if statements
B) nested if statements using AND logic
C) nested if statements using OR logic
D) four completely separate unnested if statements
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
Write structured pseudocode to show the following: if the value in the studentGrade variable is greater than or equal to RANGE1 and less than RANGE2,move "OK" to outMessage.
Significant declarations:
string outMessage
num studentGrade
num RANGE1 = 0
num RANGE2 = 101
Significant declarations:
string outMessage
num studentGrade
num RANGE1 = 0
num RANGE2 = 101
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
What techniques can you use to avoid the confusion of mixing AND and OR operators?
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
Write structured pseudocode to fix this statement:
if hourlyWage > 8.50 and < 15.80 then
if hourlyWage > 8.50 and < 15.80 then
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
There is a $10 bonus for ice cream store workers that have more than $100 of sales on their shift and sell more than four triple-scoop servings.During any one shift,there are many more workers selling more than four triple-scoop servings than workers having more than $100 in sales.When you write a program to determine bonuses,you can make the most efficient decision by first asking if workers had more than ____.
A) $100 dollars of sales
B) four triple scoop sales
C) four double scoop sales
D) four single scoop sales
A) $100 dollars of sales
B) four triple scoop sales
C) four double scoop sales
D) four single scoop sales
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
Rewrite this structured pseudocode without a NOT operator but keeping the same logic:
if NOT hourlyWage <= 20.50 then
if NOT hourlyWage <= 20.50 then
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
Double-scoop orders account for about 50 percent of the sales; single-scoop orders account for 30 percent and only 20 percent of sales are triple-scoops.When you write a program to determine sales based on scoop size,you can make the most efficient decision by asking first whether the scoop size is ____.
A) single
B) double
C) triple
D) does not mater
A) single
B) double
C) triple
D) does not mater
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
There is a $10 bonus for ice cream store workers that have more than $100 of sales on their shift and sell more than four triple-scoop servings.What pseudocode will select the workers that will earn a bonus?
A) if Sales > 100 OR tripleScoop > 4
B) if Sales > 100 OR tripleScoop >=4
C) if Sales > 100 AND tripleScoop < 4
D) if Sales > 100 AND tripleScoop > 4
A) if Sales > 100 OR tripleScoop > 4
B) if Sales > 100 OR tripleScoop >=4
C) if Sales > 100 AND tripleScoop < 4
D) if Sales > 100 AND tripleScoop > 4
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
No matter how many scoops a customer chooses,when a customer also decides that they want the ice cream served in a cone,there is an additonal 50 cent charge.In order to correctly charge for the ice cream served in a cone,you would use a(n)____.
A) OR
B) AND
C) NOT
D) > operand
A) OR
B) AND
C) NOT
D) > operand
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
Write structured pseudocode to show the following: if the value in the studentGrade variable is less that RANGE1 or greater than RANGE2,move "Error" to outMessage.
Significant declarations:
string outMessage
num studentGrade
num RANGE1 = 0
num RANGE2 = 100
Significant declarations:
string outMessage
num studentGrade
num RANGE1 = 0
num RANGE2 = 100
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck