Skip to content
ExamSpine

Lesson 1.3 · Write it

Star banner

A whole programPython or Java4 tests, 3 of them hidden

On a phone? Put the lines in order instead

Write a program that reads one line typed by the user and prints it as a banner, between two lines of stars.

  1. The first line is exactly five stars: *****.
  2. The second line is the typed line, exactly as it was typed, including any spaces at the start.
  3. The third line is five stars again, the same as the first.
  4. Print nothing else. Spaces at the end of a line are ignored.

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

In Python, read the line with input(), with nothing between the brackets. In Java, the page starts you with a class, its main method and a Scanner called scanner: read the line with scanner.nextLine().

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.

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 typed line between two lines of stars (rules 1 to 3)

    You type

    1. typed: Grand opening

    It prints

    *****
    Grand opening
    *****
solution.pySolution.java