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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!