Question
Write a complete C++ program to do the following: The main program will call a function to read in a string representing a date .
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 string. The main program will repeat the entire procedure for the next date, and the next, etc., for an entire set of datails
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 characterse.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.
As part of its job, the function breakoriginaldate should print the original date string, the three parts that it was broken into, and appropriate messages. Finally, 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 month written using two digits in all cases, a dash, the day 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 (decide how to handle this in a loop).
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
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