Question: What's wrong with the following code? Modify it to produce the intended output. Make sure to properly utilize if/else/if statements to avoid redundancy and avoid
What's wrong with the following code? Modify it to produce the intended output. Make sure to properly utilize if/else/if statements to avoid redundancy and avoid unnecessary tests. Do not use && or || in your solution.
------
"What percentage did you earn? 87
You got a B!"
-----
Java code:
int percent = readInt("What percentage did you earn? "); if (percent >= 90) System.out.println("You got an A!");
else (percent >= 80) { System.out.println("You got a B!"); } if (percent >= 70) { System.out.println("You got a C!"); } if (percent >= 60) { System.out.println("You got a D!"); } if (percent < 60) { System.out.println("You got an F!"); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
