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") ;
}
7if (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 correct tax brackets
Correct Answer:
Verified
Q25: What is the output of the following
Q26: Assuming that the user enters 60 as
Q27: What is the problem with the following
Q28: Which code snippet will output "Yes!" when
Q30: Assuming that a user enters 5 as
Q30: The two strings "Aardvark" and "Aardvandermeer" are
Q33: The switch statement in Java
A) is like
Q34: In a switch statement, if a break
Q53: Consider a situation where multiple if statements
Q74: An if statement inside another if statement
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