Suppose you want to write an if statement with multiple alternatives to print out the single tax bracket that someone is in, based on their income. Assume the integer variable income holds the annual income. What is wrong with the following if statement?
If (income < 10000)
{
System.out.println("Lowest tax bracket") ;
}
If (income < 20000)
{
System.out.println("Low-Middle tax bracket") ;
}
If (income < 30000)
{
System.out.println("Middle tax bracket") ;
}
System.out.println("High tax bracket") ;
A) The conditions are in the wrong order; the check for the highest bracket should be first
B) The conditions should use an if else/if else sequence, not just independent if statements
C) The conditions should be a switch statement instead
D) Nothing is wrong - the if statement will correctly print out the tax brackets
Correct Answer:
Verified
Q26: Assuming that the user enters 60 as
Q36: What is the conditional required to check
Q36: Consider the following code snippet:
Int number =
Q38: When an if statement is nested inside
Q40: What is the output of the following
Q53: Consider a situation where multiple if statements
Q63: Which of the following options correctly represents
Q74: Which of the following statements is true
Q81: Which of the following operators is used
Q86: When testing code for correctness, it always
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents