Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete C++ program to do the following: The main program will call a f

ID: 3572671 • Letter: W

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. 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:

   Inside a loop (you decide what type of loop and how to end it), the main program will repeat the process described below:

First, the main program will call a function readoriginaldate. The function will "send" a string, which represents a date, back to the main program.

The main program will then 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.

Finally, the main program will call a function printdate3ways which will receive three parameters. The function will use these parameters to print the date in various ways.

     The function readoriginaldate will read in and print a string of characters representing a date–e.g., "6/11/08". The function will "send" the string back to the main program. The function will do this in one of two ways: by modifying a reference parameter or by returning a value (your choice).

      The function breakoriginaldate 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 this into "5" for the month, "22" for the date, and "12" for the two-digit year.    

Assume that the original date always 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 function printdate3ways will receive three strings as parameters: the day, the month, and the year. Using these three parameters, the print function will construct and then print the date three different ways, as described below:

  (1) 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.

  (2) 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?)

  (3) 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.

  NOTE:   Do NOT print the little pieces of any of the dates one by one. Instead, do the following: Each way of representing the date must first be constructed and stored in a single 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 (for example, 5/7/13).  

STYLE: You decide exactly what parameters to send to the functions and what type of answer (if any) 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 (your output should be similar):

11/18/13 is the original date

11 is the month     18 is the day     13 is the year

18-11-13 is the European way of printing

November 18, 2013 is the American way of printing

11-18-2013 is the full way of printing

7/1/03   is the original date

7 is the month 1 is the day 03 is the year

1-7-03 is the European way of printing

July 1, 2003 is the American way of printing

07-01-2003 is the full way of printing

      After printing each date, skip a few lines on the output sheet and repeat this process for each of the remaining dates in the input.

Explanation / Answer

Please append "20"/"200" to make 14 -> 2014 or 09 -> 2009 to year

that is missing in below programme

#include <iostream>
#include<string.h>
using namespace std;

string Months[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
/**
* @brief readoriginaldate
* @param input
* This method is used to a Date String in mm/dd/yy format
* and will copy to string arguement(input)
*/
void readoriginaldate(string &input){
    cout << "Enter Date in mm/dd/yy fromat." << endl;
    getline (cin, input);
    cout<<"entered string "<<input <<" is the original date" << endl;
}
/**
* @brief breakoriginaldate
* @param input , Input String in mm/dd/yy format
* @param month , month in strinf format
* @param day , day in string format
* @param year , year in string format
* This method will retrun 3 strings data, month,year
*/
void breakoriginaldate(string input,string &month,string &day,string &year){

if( input.length() == 0){
      return;
}

int nextSlashPos = 0;

//Find Month
nextSlashPos = input.find("/");
if(nextSlashPos != string::npos){
        //month.copy((char *)input.substr(0,nextSlashPos).c_str());
      month = input.substr(0,nextSlashPos);
}

if(input.length() < (nextSlashPos +1)){
      return;
}

//Find Date
int nextSlashPos2 = input.substr(nextSlashPos +1).find("/") +(nextSlashPos + 1);
int lenghtToCpy = nextSlashPos2 - nextSlashPos -1;
if(nextSlashPos2 != string::npos){
        //month.copy((char *)input.substr(0,nextSlashPos).c_str());
      day = input.substr((nextSlashPos +1),lenghtToCpy);
}

if(input.length() < (nextSlashPos2 +1)){
      return;
}

//Find Year
int nextSlashPos3 = (nextSlashPos2 + 1);
if(nextSlashPos3 != string::npos && input.length() > nextSlashPos3){
        //month.copy((char *)input.substr(0,nextSlashPos).c_str());
      year = input.substr(nextSlashPos3);
}

//Format outpu
string output = month + " is the month" +      day + " is the day " +     year + " is the year";

cout<<output<<endl;

}
/**
* @brief printdate3ways
* @param month
* @param day
* @param year
* This method print Day, Month , Year in Different formats
*/

void printdate3ways(string month,string day,string year)
{
   string european = day+"-" + month +"-" + year + " is the European way of printing ";
   cout<<european<<endl;

   string american = Months[std::stoi(month)-1] +" " +day +"," +year +" is the American way of printing";
   cout<<american<<endl;

   string fullway = month +"-" +day +"-" +year +" is the full way of printing";
   cout<<fullway<<endl;
}

int main(int argc, char *argv[])
{
    string input ,month,day,year;
    readoriginaldate(input);
    breakoriginaldate(input,month,day,year);
    printdate3ways(month,day,year);
    cout << "Hello World!" << endl;
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote