Assignment 4

due at 6pm on Mon 3 Oct

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

Tips

Some tips, for getting full credit:

©2011 Christopher League · some rights reserved · CC by-sa