Question: 6.12 C++ please #include #include using namespace std; int DateParser(string month) { int monthInt = 0; if (month == January) monthInt = 1; else if

6.12
C++ please
6.12 C++ please #include #include using namespace std; int DateParser(string month) {

#include

#include

using namespace std;

int DateParser(string month) {

int monthInt = 0;

if (month == "January")

monthInt = 1;

else if (month == "February")

monthInt = 2;

else if (month == "March")

monthInt = 3;

else if (month == "April")

monthInt = 4;

else if (month == "May")

monthInt = 5;

else if (month == "June")

monthInt = 6;

else if (month == "July")

monthInt = 7;

else if (month == "August")

monthInt = 8;

else if (month == "September")

monthInt = 9;

else if (month == "October")

monthInt = 10;

else if (month == "November")

monthInt = 11;

else if (month == "December")

monthInt = 12;

return monthInt;

}

int main () {

while (std::getline(std::cin, date)) {

if (date == "-1") {

break;

}

std::string month = date.substr(0, date.find(" "));

int firstComma = date.find(",");

if (firstComma == std::string::npos) {

continue;

}

int day;

try {

day = std::stoi(date.substr(month.length() + 1, firstComma - month.length() - 1));

} catch (std::invalid_argument&) {

continue;

}

int year;

try {

year = std::stoi(date.substr(firstComma + 2));

} catch (std::invalid_argument&) {

continue;

}

if (months.count(month) == 0) {

continue;

}

std::cout

}

}

Complete main0 to read dates from input, one date per line. Each dates format must be as follows March 1. 1990. Any date not following thot format is incorrect and should be ignored. Use the substro function to parse the string and extract the date. The input ends with - 1 an: a line alone Output each correct date as:3-1-1990 Ex, if the input it: Mareh 1. 1990 Aptid 2 :1995 T/I5/20 Deeember 13, 2003 -1 then the cutput if 31159032122093 Uie the provided DateParaen 0 function to convert a month sting to an integor if the roonth sting is valid an intrge in the range to to 12 inclugive is returned otherwise ois returned Ex Dateparser " February") retums 2 and DateParuer( 7/15/20 )

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!