Write a program that converts dates from numerical


Objectives:
This assignment aims to use Java skills or concepts including:

* Exceptions
* modulus operator
* Classes
* User defined methods
* Input/Output Expressions

Task:
Write a program that converts dates from numerical from numerical month/day/year format to normal ''month day year format (for example 12/25/2009 corresponds to December 25, 2009).
Exceptions:
You will define three exception classes, one called MonthException, one called DayException, and one called YearException.

If the user enters anything other than a legal month number (integers from 1 to 12), your program will throw and catch a MonthException and ask the user to re-enter the month.

If the user enters anything other than a legal day number (integers from 1 to 28, 29, 30, 31 depending on the month and the year), your program will throw and catch a DayException and ask the user to re-enter the day.

If the user enters a year that is not in the range 1000 to 3000 inclusive, then your program will throw and catch a YearException and ask the user to re-enter the year.

Examples:
File listing

% ls
DateDemo.java DayException.java YearException.java
Date.java MonthException.java

Compile the Program

% javac *.java
%

Example1:
(Note: user entered values are in bold.)

% java DateDemo
Enter date to parse (MM/DD/YYYY format):
13/02/1999
Invalid month. Reenter a valid month: 
12
Parsed date: December 2, 1999
%

Example2:

% java DateDemo
Enter date to parse (MM/DD/YYYY format):
12/44/2001
Invalid day. Reenter a valid day: 
12
Parsed date: December 12, 2001
%

Example3:

% java DateDemo
Enter date to parse (MM/DD/YYYY format):
13/48/5000
Invalid month. Reenter a valid month: 
12
Invalid day. Reenter a valid day: 
14
Invalid year. Reenter a valid year: 
1999
Parsed date: December 14, 1999
%

The Program
The program will be composed of 5 files:

1. DateDemo.java
* this class will contain the main method 
2. Date.java
* this class will contain the three private variables to store a date.
* the methods needed to access and set them and manipulate them. e.g., a method that determines whether or not the year in question is a leap year. 
3. DayException.java
4. MonthException.java
5. YearException.java 

Important Notes

* Test your program on turing - that is where it will be marked.
* You must comment your program well. The program must be readable as well.

Submitting This Assignment

Your assignment must be submitted using the submit program

* This assignment is assignment a4
* You will need to submit five files for this assignment:
*
1. DateDemo.java
2. DayException.java
3. YearException.java
4. Date.java
5. MonthException.java  

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Write a program that converts dates from numerical
Reference No:- TGS0121757

Expected delivery within 24 Hours