Skip to content
ExamSpine

Lesson 1.4 · Write it

Closed sign

A whole programPython or Java4 tests, 3 of them hidden

On a phone? Put the lines in order instead

Write a program that reads the name of a place typed by the user and prints a sign on one line: the name, then a colon straight after it, then one space and closed today.

  1. The line starts with the name, exactly as it was typed.
  2. The colon comes straight after the name, with no space before it.
  3. After the colon comes exactly one space, then closed today., with a full stop at the end.
  4. Everything is on one line. Print nothing else. Spaces at the end of a line are ignored.

Your program is run several times, with a different name typed each time. Only what it prints is checked.

In Python, read the name with input(). In Java, the page starts you with a class, its main method and a Scanner called scanner: read the name with scanner.nextLine(), build the whole line with +, and print it with one System.out.println.

You cannot use these in this question:

  • .format()
  • .join()

This question practises joining text with +, so build the whole line with + and print it once. The ways of building text listed here are not allowed.

Running Java here comes later. You can put this answer's lines in order instead. 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.

You cannot use these in this question:

  • .print()
  • .printf()
  • .format()
  • .join()

This question practises joining text with +, so build the whole line with + and print it once. The ways of building text listed here are not allowed.

Examples

Your program is run 4 times: the example below, and 3 hidden ones that check the rules above. Only what it prints is checked.

  • the name, the colon, then the rest of the sign (rules 1 to 4)

    You type

    1. typed: The library

    It prints

    The library: closed today.
solution.pySolution.java