Skip to content
ExamSpine

Lesson 6.6 · Answer it

Booking boundary bug

5 marksYou mark it yourself against the marking points

A cafe takes table bookings for groups of 1 to 8 people. This program checks the group size. In Java it runs inside a main method, with Scanner imported.

size = int(input())
if size >= 1 and size <= 9:
    print("Booked")
else:
    print("Size must be 1 to 8")
Scanner scanner
    = new Scanner(System.in);
int size = Integer.parseInt(
    scanner.nextLine());
if (size >= 1 && size <= 9) {
    System.out.println("Booked");
} else {
    System.out.println(
        "Size must be 1 to 8");
}

(a) A student tests the program with 4 and with 12, and both give the right output. State which kind of test data 4 and 12 each are. [2]

(b) The program has a logic error. Identify a test value that shows it, and state what the program prints for that value. [2]

(c) The student adds a test with 8, and the program prints the right output for it too. Explain why the test with 8 does not show the error. [1]

[5]