Question: Write a commented C++ program to re-format dates. Prompt the user to input a date in the form: Sunday, January 2, 2010. Display the date

Write a commented C++ program to re-format dates. Prompt the user to input a date in the form:

Sunday, January 2, 2010. 

Display the date in each of the following formats:

January 2 was a Sunday in 2010 Sun, Jan 2 10 2010-01-02 

Write commented C++ code which will use getline(cin,someString) to get a string from the user (in the form shown above), and then extract the day, month, date, and year into separate string variables. To do this you will have to search the input string for substrings or characters that will uniquely identify each portion of the string you plan to extract, in order. Test your code with various different dates to make sure the extraction process is working properly.

Furthermore, Write commented C++ code which will use the strings extracted in the code you wrote out the date in the formats given. You will need to employ substring functions for the second format. For the third format, you will need to convert from the month in string format to the numerical value for that month; for example,January should be converted to 01. In order to accomplish this, you are provided with the file months.txt containing the months and their corresponding numbers, for example 01January 02February etc. Use getline(yourFile,yourString) to read in a string from the file, and use the yourstring.find() function to search for the month and extract the corresponding number which immediately precedes it.

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!