Question
Write a C++ program that asks user for birthday, then displays the user's age by Feb. 22, 2023 if the birthday is valid. Steps: 1-declare
Write a C++ program that asks user for birthday, then displays the user's age by Feb. 22, 2023 if the birthday is valid.
Steps:
1-declare variables needed for the program
2-prompt user to enter the birthday in the order of Year, Month, Date. Month must entered by the first 3 letters, with first letter in capital. ie, Jan, Dec, etc...
3-read in the datas in one instruction
4-validate the birthday as following, and terminate the program if the birthday is not a valid day
Jan, Mar, May, Jul, Aug, Oct, Dec has 31 days Apr, Jun, Sep, Nov has 30 days
Feb has 29 days (You don't have to worry about nonleap years)
5-Calculate user's age, by comparing the year and month with 2023 Feb., compare the date when user is born in Feb.
6-Display user's age
Sample1:
Please enter your birthday in the order of year, Mon(Frist 3 letters of month 1St in cap), date. Separate each value by a space
user input>2004 Jan 23
You're 19 by Feb. 22, 2023.
Sample 2:
Please enter your birthday in the order of year, Mon(Frist 3 letters of month 1st in cap), date. Separate each value by a space user_input>2004 Mar 10
You're 18 by Feb. 22, 2023.
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