Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C++ program using if-else statements, switch statements, and/or loops (for, while, do- while) that prints a months calendar after prompting the user inputs.
Write a C++ program using if-else statements, switch statements, and/or loops (for, while, do- while) that prints a months calendar after prompting the user inputs. Your program must validate all the user inputs (or keep prompting the user inputs until the user enters valid inputs), display a formatted calendar, ask the user if they want to print another calendar (y), repeat the program until the user enters 'n', and then exit with the final message.
Note:
You can use setw() function in the library
Program Inputs
Enter a month (1 to 12):
- If user enters an invalid option, keep displaying this prompt until a valid input is entered Enter days in the month (28, 29, 30, or 31):
- If user enters an invalid option, keep displaying this prompt until a valid input is entered Enter start day (0 to 6):
- If user enters an invalid option, keep displaying this prompt until a valid input is entered
Program Outputs
A formatted calendar is displayed according to the valid user inputs (see the sample output
below).
Would you like to print another month (y)?
- A Question for repeating (y)
- User will always enter y or n.
- If user enters y, display the initial prompt Enter a month (1 to 12): again.
- If user enters n, display the final message Thank you for using this program. Goodbye!
and terminate the program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started