Question
6.12 C++ please #include #include using namespace std; int DateParser(string month) { int monthInt = 0; if (month == January) monthInt = 1; else if
#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
}
}
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