Let's get started with a program that uses the switch
conditional!
- Login to your Repl.It account.
- Click on:
Languages
- In the
Popular
section choose: Java: A concurrent, class-based, statically typed object-oriented language.
- Click the
pencil
icon next to your repl name.
- In the
Default name:
input box type: Grade
- Delete all the lines of code provided as an example.
- Copy the
Grade.java
Template (Java) code (below)
- Paste that code into your new Grade class in the editor
- Change the
@author put-your-lastname-here
- Replace the blank on the
int
line with a grade between 0 and 100
- After the
} else {
for the 'C' grade, add:
} else if (grade > 59) {
letterGrade = 'D';
- After the
case 'D':
line print out a message for a 'D' grade
and a break;
statement.
- Click the Run icon
Grade.java
Template (Java)
Grade
Class Output