Assignment 4

Due Monday 1 October at 1am.

Write a program that will:

  1. Ask the user for a month (input as an integer 1–12).

  2. Ask the user for a day of the month.

  3. Give an error message if month is out of range.

  4. Give an error message if day is out of range for that month (such as April 31st).

  5. If there are no errors, then print out the date using the full name of the month, such as “March 25th.”

Here are a few sample runs of the program, but it should work for other numbers as well.

Enter month (1-12): 3
Enter day of month: 25
March 25th
Enter month (1-12): 0
ERROR: invalid month
Enter month (1-12): 4
Enter day of month: 31
ERROR: invalid day
Enter month (1-12): 12
Enter day of month: 0
ERROR: invalid day
Enter month (1-12): 11
Enter day of month: 23
November 23rd

Some tips, for getting full credit:

  • Make sure you use appropriate indentation and alignment of braces.

  • Include a comment at the top with your name and the date.

Please save your solution in calendar.cpp in the a04 folder. (Use “Sync with git” to create this file.)