I'm very new to C++ and have an assignment that is due tomorrow that i really need help on. The prompt is this...
Prompt the user for two calendar dates. A calendar date consists of a valid month, day and year in the format: Month D[D], YYYY. In other words, there will be a one word month, followed by a one or two digit day in the month, then a comma, and then a four-digit year. The year must be 1582 or later (when the Gregorian calendar was adopted). If the user enters an invalid date (e.g. September 31, 2016, Quintember 10, 2001, or October 12, 1492), your program must reprompt the user until a valid date is entered. You will need to handle invalid months (e.g. Quintember), invalid years (e.g. AD2016), but you may assume that the day will be a proper integer (with the comma) though perhaps one that is out of range. Once you have two valid dates, compute and report the number of days between the two valid dates. E.g. "There are 14 days between March 1, 2016 and March 15, 2016." or "There is 1 day between July 24, 1846 and July 23, 1846." Note that the dates can be in chronological order (first before second) or reverse chronological order (second before first), but the number of days will be the same.
Im pretty lost on all of it, i've tried just using a lot of if statements and bools for the verification stuff but I can't figure out how to make it all work together. Any help at all would be great, thank you!!
You should create Date class. Create constructor that throws exception if date you're trying to create is invalid. Probably if this your assignment you know what classes are. Looks like you also have to overload operator<< for your Date to report your calculations like this
"There are 14 days between March 1, 2016 and March 15, 2016."
Than you create int Date::operator-(const Date&); Don't forget to also take care of leap years, and different count of days in each month when calculating difference between 2 Dates.
Using just if statements this would be hard to do indeed.