Exam 5: Making Decisions

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

When using equals and not equals for comparisons with objects, you compare the objects' ____ instead of actual values.

(Multiple Choice)
4.9/5
(73)

Create an if statement that checks if the variable salesAmt is greater than or equal to the QUOTA_AMT constant. Use the logical OR operator to also check if salesAmt is greater than or equal to the HIGH_SALES constant. If either expression is true, assign the value of the LARGE_QUOTA constant to the variable bonusAmt.

(Essay)
4.8/5
(81)

You write pseudocode in everyday language, not the syntax used in a programming language.

(True/False)
4.8/5
(83)

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.9/5
(74)

Create an if statement that will check if the variable salesAmt is greater than the constant SALES_QUOTA. If true, create a block statement that will calculate salesAmt * BONUS_PERCENT and store the result in a variable named bonusPay. The block statement will then compute totalPay by adding salesAmt to bonusPay. Outside of the if structure, add a println statement that will output the totalPay value.

(Essay)
4.9/5
(74)

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
(86)

____________________ statements are particularly useful when two conditions must be met before some action is taken.

(Short Answer)
4.7/5
(76)

A logical structure called a(n) ____ structure is when one step follows another unconditionally.

(Multiple Choice)
4.8/5
(77)

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.8/5
(75)

Failing to include a complete ____ on each side of an && operator in an if statement is a common error in Java programming.

(Multiple Choice)
4.8/5
(70)

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.7/5
(83)

The ____ operator is always evaluated before the OR operator.

(Multiple Choice)
4.7/5
(74)

The ____ operator is written as the exclamation point ( ! ).

(Multiple Choice)
4.7/5
(83)

You can leave out the ____ statements in a switch structure.

(Multiple Choice)
4.9/5
(69)

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

(Short Answer)
4.7/5
(75)

Describe how a sequence structure works.

(Essay)
4.8/5
(74)

Create a switch statement that will test the value of a variable named score. If score has a value of 5, create a println statement that will output "Excellent". If score has a value of 4, create a println statement that will output "Great". If score has a value of 3, create a println statement that will output "Good". If score has a value of 2, create a println statement that will output "Fair". If score has a value of 1, create a println statement that will output "Needs improvement". If score does not contain a matching value for any of the case statements, create a println statement that will output "Retake test".

(Essay)
4.9/5
(75)

Why would a programmer execute more than one statement that depends on the evaluation of a Boolean expression, and how could he or she do it in Java?

(Essay)
4.9/5
(77)

Computers contain switches that are set to on or off.

(True/False)
5.0/5
(85)

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

(Multiple Choice)
4.8/5
(82)
Showing 21 - 40 of 70
close modal

Filters

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