Problem description

We continue working with Gregorian dates for this assignment. Your program will prompt the user to enter a date and a non-negative integer, N. You are to find the date in the calendar N days from the given date.

Your program should continuously prompt the user to enter a date in the form yyyy-mm-dd. year is an integer greater than 1752, month is an integer in the range 112, and day is an integer in the range 131. N is a non- negative integer in the range 0 < N < 10000. Your program will continue to prompt the user to enter a date and the number of days in the future until the user enters 0-0-0.

Handle input failure gracefully. If the user enters invalid data, display a meaningful message, then continue normal processing. Failed inputs do not count toward the total number of cases.

You can use the Linux date command to validate your programs output. For example, the date 90 days after 2017-01-01 can be found by:

$ date -d '2017-01-01 +90 days' '+%Y-%m-%d'
2017-04-01

For each input, output the case number followed by the date after N days in the same format as the input. Look at the sample below for exact format:

Sample interaction

$ ./pa05
Enter a date in the form yyyy-mm-dd (0-0-0 to quit): 1776-07-04
Enter the number of days to add: 365
Case 1: 1777-07-04
Enter a date in the form yyyy-mm-dd (0-0-0 to quit): 2017-01-01
Enter the number of days to add: 90
Case 2: 2017-04-01
Enter a date in the form yyyy-mm-dd (0-0-0 to quit): 0-0-0
$
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.