Assignment 3

due at midnight on   +40

The objective of this assignment is to explore using nested conditional and switch statements. Create a file called a3.cpp in your cs102 folder – that’s the filename I will look for when I am grading.

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.”

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.

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