Skip to content
ExamSpine

Lesson 2.7 · Write it

Weekend check

A whole programPython or Java6 tests, 3 of them hidden

On a phone? Put the lines in order instead

Write a program that reads a day number (1 for Monday through 7 for Sunday) and prints whether it is a weekday or the weekend.

  1. Always print Day: followed by the day number on the first line.
  2. If the day is 6 (Saturday) or 7 (Sunday), print Weekend. Otherwise, print Weekday.
  3. Spaces at the end of a line are ignored.
  4. The day number is always between 1 and 7.

Your program is run several times. Only what it prints is checked.

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 6 times: the 3 examples below, and 3 hidden ones that check the rules above. Only what it prints is checked.

  • Saturday: Weekend (rule 2)

    You type

    1. typed: 6

    It prints

    Day: 6
    Weekend
  • a weekday (rule 2)

    You type

    1. typed: 3

    It prints

    Day: 3
    Weekday
  • Sunday: Weekend (rule 2)

    You type

    1. typed: 7

    It prints

    Day: 7
    Weekend
solution.pySolution.java