Let's get started with a program that uses the switch
conditional!
- Open Eclipse
- Right-Click on your
edu.buffalostate.cis425.fa10.exercises..your-username
- Choose:
File -> New -> class
- In the
Name:
textbox type: Grade
- Click:
Finish
- Copy the
Grade.java
Template (Java) code (below)
- Paste that code into your new Grade class in the editor
- Change both occurrences of 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