CSC 175 - Intermediate Programming
Dr. R. M. Siegfried
Assignment #20 - Converting Date format and Catching Exceptions for Bad
Data
Due Monday, April 15, 2024
Write a program that converts dates from numerical month/day/year
format to normal "month day, year" format (e.g., 4/6/2018
becomes April 6, 2018 ).
You will define three exception classes one called
MonthException
, another called
DayException
, and a third called
YearException
.
- If the user enter anything other than a legal month number (integers 1
through 12), your program will throw and catch
MonthException
and ask the user to re-enter then month.
- Similarly, if the user enters anything other than a valid day number
(integers 1 through 28, 29, 30, or 31 depending on the month and year), then
your program will throw and catch a
DayException
and ask the user to re-enter the day.
- If the user enter a year outside the range 1000 through 3000 (inclusive),
then your program will throw and catch a
YearException
and ask the user to re-enter the year.
[Back to the Assignments List]