Monday, November 7, 2011

Lab 12 - day of year

As one of the requirements to earn a B- or higher, you must complete exercise 5 on p 409, a program to calculate which day of the year the user entered. At the very minimum, you will need to write two functions. These are their headers:

   bool isLeapYear(int y)
   int countDays(int m, int d, bool leap)


Your program logic should work as follows. Request a date from the user. Parse the date string into month, day, and year. Validate all input, that is, if the user enters 13 for the month, you should trap that error and provide a suitable error message to the user.

After all validations, you need to call isLeapYear to know whether to count 28 or 29 days for February then you invoke countDays to add up all the days between January 1st and the date the user entered, inclusive.

Sample Output
Here is a screenshot of my code running.

Day of year output

Refer to the deliverables post for comment formatting and required program identification information.

Due Date:
Sunday, November 13th, 6:00pm