Exam 3: Decision Structures

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

Which of the following correctly tests the char variable chr to determine whether it is not equal to the character B?

Free
(Multiple Choice)
4.7/5
(42)
Correct Answer:
Verified

C

What is the value of ans after the following code has been executed? int x = 40; Int y = 40; Int ans = 0; If (x = y) Ans = x + 10;

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

D

This is a boolean variable that signals when some condition exists in the program

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

C

What will be the value of x after the following code is executed? int x = 75; Int y = 60; If (x > y) X = x - y;

(Multiple Choice)
4.8/5
(35)

The if/else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false.

(True/False)
5.0/5
(47)

What would be the value of discountRate after the following statements are executed? double discountRate = 0.0; Int purchase = 100; If (purchase > 1000) DiscountRate = .05; Else if (purchase > 750) DiscountRate = .03; Else if (purchase > 500) DiscountRate = .01;

(Multiple Choice)
4.8/5
(39)

What will be the value of pay after the following statements are executed? int hours = 45; Double pay,payRate = 10.00; Pay = hours < = 40 ? hours * payRate : 40 * payRate + (hours - 40)* payRate * 1.5;

(Multiple Choice)
4.7/5
(48)

What would be the value of bonus after the following statements are executed? int bonus,sales = 1250; If (sales > 1000) Bonus = 100; If (sales > 750) Bonus = 50; If (sales > 500) Bonus = 25; Else Bonus = 0;

(Multiple Choice)
4.9/5
(36)

If chr is a character variable,which of the following if statements is written correctly?

(Multiple Choice)
4.8/5
(35)

What will be the values of ans,x,and y after the following statements are executed? int ans = 35,x = 50,y =50; If ( x >= y) { Ans = x + 10; X -=y; } Else { Ans = y + 10; Y += x; }

(Multiple Choice)
4.9/5
(46)

What will be the values of ans,x,and y after the following statements are executed? int ans = 0,x = 15,y =25; If ( x >= y) { Ans = x + 10; X -=y; } Else { Ans = y + 10; Y += x; }

(Multiple Choice)
4.9/5
(37)

When testing for character values,the switch statement does not test for the case of the character.

(True/False)
4.9/5
(43)

What will be the value of bonus after the following code is executed? int bonus,sales = 10000; If (sales < 5000) Bonus = 200; Else if (sales < 7500) Bonus = 500; Else if (sales < 10000) Bonus = 750; Else if (sales < 20000) Bonus = 1000; Else Bonus = 1250;

(Multiple Choice)
4.9/5
(39)

What will be printed when the following code is executed? double x = 45678.259; DecimalFormat formatter = New DecimalFormat("#,##0.0"); System.out.println(formatter.format(x));

(Multiple Choice)
4.8/5
(34)

What will be the value of ans after the following code has been executed? int ans = 10; Int x = 65; Int y = 55; If (x >= y) Ans = x + y;

(Multiple Choice)
4.8/5
(27)

A block of code is enclosed in a set of

(Multiple Choice)
4.8/5
(34)

What will be printed when the following code is executed? double x = 45678.259; DecimalFormat formatter = New DecimalFormat("#,###,##0.00"); System.out.println(formatter.format(x));

(Multiple Choice)
4.8/5
(35)

What will be the value of charges after the following code is executed? double charges,rate = 7.00; Int time = 180; Charges = time < = 119 ? rate * 2 : Time / 60.0 * rate;

(Multiple Choice)
4.8/5
(37)

Which of the following expressions will determine whether x is less than or equal to y?

(Multiple Choice)
4.8/5
(44)

What would be the value of discountRate after the following statements are executed? double discountRate = 0.0; Int purchase = 1250; Char cust = 'N'; If (purchase > 1000) If (cust == 'Y') DiscountRate = .05; Else DiscountRate = .04; Else if (purchase > 750) If (cust == 'Y') DiscountRate = .04; Else DiscountRate = .03; Else DiscountRate = 0;

(Multiple Choice)
4.8/5
(25)
Showing 1 - 20 of 52
close modal

Filters

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