Skip to content

Letter grade

Java switch over ranges

Flowchart (ISO 5807)

YesNoYesNoStartInput ss / 10 = 10 or s / 10 = 9Return «A»Ends / 10 = 8Return «B»EndReturn «F»EndFigure 1 — G.letter

Source code

Java
class G {
    static char letter(int s) {
        switch (s / 10) {
            case 10:
            case 9: return 'A';
            case 8: return 'B';
            default: return 'F';
        }
    }
}

The editor opens with this code — change it and the chart redraws.

Language
Java
Constructs
switch over ranges
Topic
Switch / case
Formats
Word, Visio, draw.io, PDF, SVG

Related examples