005-003-007

Switch Statement: Day of Week Determination

Medium

Problem Description

switch statement: Day of Week Determination

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

Learning Objective: Understand how to write multi-branch processing efficiently using switch statements

Overview

Create a program using a switch statement that reads a number from 1 to 7 from standard input and outputs the corresponding day of the week. Also implement error handling for out-of-range values.

Specifications

  • Read one integer from standard input
  • Determine day of week with switch statement as follows
    • 1: Monday
    • 2: Tuesday
    • 3: Wednesday
    • 4: Thursday
    • 5: Friday
    • 6: Saturday
    • 7: Sunday
    • Other: Invalid day number

Input Format

3

Output Format

Wednesday

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