Question
This must be done in C++ format and before continuing to post please read the IMPORTANT NOTES first, which i will post below after the
This must be done in C++ format and before continuing to post please read the IMPORTANT NOTES first, which i will post below after the question. This home work is actually done but it just needs a few requirements to be totally complete. I will post my solution after the important notes.
Question: Write a program that prompts the user to enter a person's date of birth in numeric form such as 8/27/1980. The program then outputs the date of birth in the form: August 27, 1980. Your program must contain at least two exeception classes: invalidDay and invalidMonth. If the user enters an invalid value for day, then the program should throw and catch an invalidDay object. Similar conventions for the invalid values of month and year. (Note that your program must handle a leap year.)
IMPORTANT NOTES: The program is actually done, with all the the exception caught. but the problem is that it needs a continuous menu required to allow for testing the code. it needs an input from the user, asking if they would like to continue with an input. This needs to be asked again after the user enters the previous date of birth, asking if they would like to input another date of birth, if yes, loop with the previous question, if no, exit program. it also needs to ask the user again when they caught an exception, to put the right input. until the input is correct, they will keep asking the user to try again. currently, the program will end after catching each exception, and that is the problem. I don't think the header files needed to be changed at all since it catches all exception properly. so the problem is the main file which needs the exit program and the loop for try again. Before posting your solution, please make sure the program runs and compiles first. I would appreciate your help for this
my code:
//invalidDay.h #include
public: invalidDay() { msg = "Day input is wrong"; } void showException() { cout << msg << endl; } };
================================================
//invalidMonth.h #include
====================================
//leapYear.h #include
=====================================
//main.cpp #include
void read_date(int &day, int &month, int &year); int main() { int day, month, year; string months[12] = {"january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"}; try { read_date (day, month, year); cout << "Date of Birth " << months[month-1] << " " << day << ", " << year<
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