Question: Write a program that prompts the user to enter the date in mm/dd/yyyy format. The program should use a single input statement to accept the
Write a program that prompts the user to enter the date in mm/dd/yyyy format. The program should use a single input statement to accept the date, storing each piece of the date into an appropriate variable. Demonstrate that the input was obtained correctly by outputting the month, day, and year to the screen as shown in the example output below.
Enter date (mm/dd/yyyy): 2/06/2022 Month entered: 02 Day entered: 06 Year entered: 2022
Enter date (mm/dd/yyyy): 12/1/200 Month entered: 12 Day entered: 01 Year entered: 200
Although the user entered 06 in the first example, C++ drops the 0 as insignificant when the program outputs the value. After getting your program working, adjust the output to always output two-digit months and days. For example, 6 should output as 06, and 10 should output as 10 (not 010). You must store the input as int values; do NOT use string variables. Hint: You will need two parameterized manipulators that we talked about from the iomanip library. Think about the fact that you always want two characters, but if the input is a single digit, then the other character needs to be a '0' instead of a ' '.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
