005-004-010

Day of Week Finder

Medium

Problem Description

In this problem, you will create a program that reads an integer (1–7), determines the corresponding day of the week using a switch statement, and displays the result to standard output.

Input Format

One line contains an integer from 1 to 7, or an integer outside the range.

Output Format

Output the day of the week judged using a switch statement.

  • 1: "Monday"
  • 2: "Tuesday"
  • 3: "Wednesday"
  • 4: "Thursday"
  • 5: "Friday"
  • 6: "Saturday"
  • 7: "Sunday"
  • Others: "Invalid day"

Constraints

  • Input is an integer

Key Points

  • Switch statements are convenient when checking equality against multiple values
  • Don't forget to write break statements at the end of each case label
  • Handle out-of-range values with the default case

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up