Exam 5: Making Decisions

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

  Using the above flowchart and code, why will the above statements execute but provide unintended results? Write the statement correctly. Using the above flowchart and code, why will the above statements execute but provide unintended results? Write the statement correctly.

Free
(Essay)
4.9/5
(70)
Correct Answer:
Verified

There should be no semicolon at the end of the first line of the if statement following the parentheses because the statement does not end there. The statement should end after the println() call, so that is where you type the semicolon. 
if(quizScore == 10)
System.out.println("The score is perfect");

   Use the above flowchart to create the code using the logical && operator to determine if a SALES_BONUS will be assigned to the variable bonus . Use the above flowchart to create the code using the logical && operator to determine if a SALES_BONUS will be assigned to the variable bonus .

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

if(itemsSold > MIN_ITEMS && totalValue >= MIN_VALUE)
   bonus = SALES_BONUS;

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

Free
(Multiple Choice)
4.8/5
(88)
Correct Answer:
Verified

B

An alternative to using a Boolean expression, such as someVariable == 10 , is to store the Boolean expression's value in a Boolean variable.

(True/False)
4.9/5
(66)

When you use the && operator, you must include a complete _____ on each side.

(Multiple Choice)
4.9/5
(78)

The ____ statement is useful when you need to test a single variable against a series of exact integer, character, or string values.

(Multiple Choice)
4.8/5
(70)

Although not required, it is common procedure to align the keyword if with the keyword else .

(True/False)
4.9/5
(79)

Although it is possible to block statements that depend on an if , you cannot likewise block statements that depend on an else .

(True/False)
5.0/5
(77)

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

(Multiple Choice)
4.8/5
(67)

What is a range check?  Provide an example of a range check using a series of if..else statements using the values defined below. final double HIGH_LIM = 1000.00; final double HIGH_RATE = 0.08; final double MED_LIM = 500.00; final double MED_RATE = 0.06; final double LOW_RATE = 0.05;

(Essay)
4.9/5
(76)

The ____ requires three expressions separated with a question mark and a colon.

(Multiple Choice)
4.8/5
(77)

You are never required to use a switch structure; you can always achieve the same results with nested ____________________ statements.

(Short Answer)
5.0/5
(89)

In Boolean expressions, when you want to execute more than one statement based on the results of the expression, you place statements within a block. What is a block and why is it important in decision statements? Why are curly braces crucial when blocking an if statement?

(Essay)
4.8/5
(87)

When you place a block within an if statement, it is crucial to place the ____ correctly.

(Multiple Choice)
4.9/5
(78)

public class Student {     private int studentNum;     private int studentScore;     public int MAX_NUM = 500;     public int MAX_SCORE = 100;     Student(int num, int score)     {     } Decision making can be used to control the allowed values in an object's fields. In the above code, the Student class contains two fields that hold a student number and a score. A constructor accepts values for these fields as parameters. Write the code between the curly brackets that will determine whether the value of num is less than the MAX_NUM constant. If true, assign the value of num to studentNum . Otherwise, assign the value of MAX_NUM to the studentNum . Then check if the value of score is less than or equal to MAX_SCORE . If true, assign the value of score to studentScore . Otherwise, assign 0 to studentScore .

(Essay)
4.8/5
(72)

if (maxValue = 100) System.out.println ("Your limit has been reached"); Why is the above if statement illegal? How would you fix it?

(Essay)
5.0/5
(81)

A ____ checks a value, and based on the result performs one of two actions.

(Multiple Choice)
4.8/5
(85)

The ____ operator is always evaluated before the OR operator.

(Multiple Choice)
4.9/5
(88)

What is a conditional operator? Show an example of an expression that uses a conditional operator.

(Essay)
4.8/5
(88)

You can use the ____, which is written as || , if you want some action to occur when at least one of two conditions is true.

(Multiple Choice)
4.8/5
(89)
Showing 1 - 20 of 66
close modal

Filters

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