Exam 5: Making Decisions

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Explain the use of the NOT operator.

Free
(Essay)
4.7/5
(84)
Correct Answer:
Verified

You use the NOT operator, which is written as the exclamation point ( ! ), to negate the result of any Boolean expression. Any expression that evaluates as True becomes False when preceded by the NOT operator; and accordingly, any False expression preceded by the NOT operator becomes True.

Why would a programmer need to use a range check? Give an example.

Free
(Essay)
4.8/5
(73)
Correct Answer:
Verified

A range check is a series of statements that determine within which of a set of ranges a value falls. Consider a situation in which salespeople can receive one of three possible commission rates based on their sales.

When an expression containing a ____ is part of an if statement, the assignment is illegal.

Free
(Multiple Choice)
5.0/5
(78)
Correct Answer:
Verified

A

Explain the difference between a single-alternative if structure and a dual-alternative if structure. When would it be necessary to use a dual-alternative if structure?

(Essay)
4.9/5
(82)

Match each term with the correct statement below. -Used in the OR operator

(Multiple Choice)
4.8/5
(83)

Range checking and the switch statement are tools programmers can use for effective decision making.

(True/False)
4.9/5
(92)

An alternative to using a Boolean expression, such as quizScore == 10, is to store the Boolean expression's value in a Boolean variable. How could you express this in Java?

(Essay)
4.7/5
(74)

Write a nested if statement that will check if the variable qtySold is greater than the QTY_QUOTA constant. If true, evaluate a second expression that will check if the variable totalSales is greater than the constant SALES_QUOTA. If the second expression is also true, create an assignment statement that will assign the constant BONUSAMT to the variable bonus. After BONUSAMT is assigned, the if structure ends.

(Essay)
4.7/5
(77)

Both & and | are valid Java operators, but they operate on ____________________ rather than making comparisons in logical conditions as && and || do.

(Short Answer)
5.0/5
(84)

List and explain the keywords used with the switch statement.

(Essay)
4.8/5
(82)

A ____ consists of written steps in diagram form, as a series of shapes connected by arrows.

(Multiple Choice)
4.8/5
(80)

if (quotaAmt > 100 || sales > 100 && productCode == "C") bonusAmt = 50; When the above code is executed, which operator is evaluated first?

(Multiple Choice)
5.0/5
(81)

if(qtySold > QUOTA) bonusPay = 50; totalPay = regPay + bonusPay; System.out.println("Your totalPay amount is " + totalPay); Why is the above code incorrect? What would be required to make the code execute correctly?

(Essay)
4.9/5
(74)

When you block statements, you must remember that any ____ you declare within a block is local to that block.

(Multiple Choice)
4.7/5
(86)

A(n) ____________________ structure is one that involves choosing between alternative courses of action based on some value within a program.

(Short Answer)
4.8/5
(84)

if(firstValue == secondValue) { int total = firstValue + secondVaue; System.out.println("The values are equal"); } System.out.println("The total is " + total); Why will the above println() statement cause an error?

(Essay)
4.9/5
(79)

Match each term with the correct statement below. -Two possible courses of action

(Multiple Choice)
4.8/5
(83)

When you execute an if…else statement, only one of the resulting actions takes place depending on the evaluation of the ____ following the if.

(Multiple Choice)
4.8/5
(85)

Create an if…else statement that will check if the maxValue variable is equal to 100. If true, create a println statement that will output "Max reached". If false, create a println statement to output "Keep trying".

(Essay)
4.9/5
(58)

Match each term with the correct statement below. -The logical NOT operator

(Multiple Choice)
4.9/5
(92)
Showing 1 - 20 of 70
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)