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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!