Write a complete C++ program to do the following: The main program will call a function to read in a string representing a date. The main program will call several other functions to process that date. The main program will repeat the entire procedure for the next date, and the next, etc., for an entire set of data.

Here are the details: In a loop (you decide how to end it), the main program will call a function readoriginaldate which will read in and print a string of characters –e.g., "6/11/08"

The function will "send" the string, which represents a date, back to the main program. The function will do this by modifying a reference parameter or by returning a value (your choice). The main program will repeat the process described below for each string read in:

The main program will send the original date to a function breakoriginaldate which will break the original date into three pieces: a month, a day, and a two-digit year. The month will be the first part (up to the first slash) of the original date, the day will be the second part (up to the second slash), and the two-digit year will be the third part (after the second slash) of the original date.

For example, if the original date string is "5/22/12", the function will separate it into "5" for the month, "22" for the date, and "12" for the two-digit year.

Assume that the original date has the following format: there is a number, then a slash, then another number, a second slash, and finally one last number.

The function breakoriginaldate should print the original date string, the three parts that it was broken into, and appropriate messages. The function should use three reference parameters to "send" these three parts back to the main program for later use.

For example, the function could print the following:

5/22/12 is the original date
5 is the month 22 is the day 12 is the year

The function will "send" the three strings 5, 22, and 12 back to the main program. The main program will call a function printdate3ways which will receive three strings, the day, the month, and the year, as parameters. Using these three parameters, the print function will store and then print the date three different ways, as described below:

  • The first way will be the day, then a dash, then the month, then a dash, then the year. For example, 22-9-12. Call this the European way of printing.
  • The second way will be the English word for the month, the day, a comma, a space, and then the year written using 4 digits (20 and then the two-digit year). For example, September 7, 2012. Call this the American way of printing. [You must decide how to compute the English word from the number – what are some choices?]
  • The third way will be the day written using two digits in all cases, a dash, the month written using two digits in all cases, a dash, and then the four-digit year. For example, 03-11-2012. Call this the full way of printing.

Skip a few lines on the output sheet and repeat this process for each of the remaining dates in the input.

NOTE: Do NOT print the little pieces of a date one by one. Instead, do the following: Each way of representing the date must first be stored in a string variable, then printed from that string variable with an appropriate message.

DATA: Have a total of 10 or more input strings. Have at least three months and at least three days which are just a single digit. Have a date whose month and day are both exactly one digit.

STYLE: You decide exactly what parameters to send to the functions and what type of answer to return. Be sure that each function has a good comment explaining what parameter(s) it receives, what it does, and what (if anything) it returns.

OUTPUT: Here is some sample output (yours should be similar):

5/22/12 is the original date
5 is the month 22 is the day 12 is the year
22-5-12 is the European way of printing
May 22, 2012 is the American way of printing
05-22-2012 is the full way of printing
12/1/03 is the original date
12 is the month 1 is the day 03 is the year
1-12-03 is the European way of printing
December 1, 2003 is the American way of printing
12-01-2003 is the full way of printing
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.