Question 8-2

Say the user runs the following program, typing 4 when told. What does the program print?

import csbsju.cs160.*;
public class Example {
    public static void main(String[] args) {
        IO.print("Type something. ");
        switch(IO.readInt() / 2) {
        case 0: IO.println("0");
        case 1: IO.println("1");
        case 2: IO.println("2");
        case 3: IO.println("3");
        case 4: IO.println("4");
        case 5: IO.println("5");
        }
    }
}

Solution

2
3
4
5

Back to Review for Quiz 8