Skip to content
ExamSpine

Lesson 1.2 · Write it

Cafe menu

A whole programPython or Java1 test

Write a program that prints this small menu: a title, then one empty line, then two items, each on its own line.

Cafe menu

Tea
Toast
  1. The four lines come in the order shown, and the second line is empty.
  2. There is exactly one empty line, between the title and Tea.
  3. Everything is checked exactly: capitals and spaces. Print nothing else. Spaces at the end of a line, and empty lines after Toast, are ignored.

The program reads no input. In Python, print() with nothing between the brackets prints an empty line. In Java, System.out.println() with nothing between the brackets does the same. The page starts you with a class and its main method: write your instructions between the braces of main.

Running Java here comes later. You can still write your Java answer (it stays while this page is open) and compare it with our worked solution. Or try this exercise in Python.

Examples

Your program is run once, as in the example below. Only what it prints is checked.

  • the title, one empty line, then the two items (rules 1 to 3)

    You type

    Nothing

    It prints

    Cafe menu
    
    Tea
    Toast
solution.pySolution.java