Switch, break, and default


Saturday, November 11, 2023 Difficulty: Easy

Objective

Create a Java program that calculates a student''''s grade based on an integer input. Request a number (x) from the user and respond as follows:

  • 10 - Honor Roll
  • 9 - Outstanding
  • 7,8 - Very Good
  • 6 - Good
  • 5 - Pass
  • 0,4 - Fail

Utilize the switch statement with break and default cases in Java.

Input

10

Output

Honor Roll

Solution

Click here to view the exercise solution

Share it

Share it on your social media and challenge your friends to solve programming problems. Together, we can learn and grow.

Copied

The code has been successfully copied to the clipboard.

More Exercises

Continue improving your Java programming skills with our selection of practical exercises from the lesson. Click on Practice and challenge your knowledge!

1

Basic calculator using if

Java basic calculator. Input numbers and operators (+, -, x, /) for calculation. If the symbol is not valid, it displays 'Character not recognized'.

Flow controls: Conditions

Practice with exercises in Java related to the conditions, loops and structures of the language.

Practice exercises

Keep learning

C# Programming Course

Free programming course with practical exercises and solutions in C#. Start learning right now!

CookieOwn and third party cookies to improve our services. If you go on surfing, we will consider you accepting its use.