Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task The task is to read a file, which consists of one date on each line. Each date should be stored in a Date abject.
Task The task is to read a file, which consists of one date on each line. Each date should be stored in a Date abject. If the next date is later than the previous date, a DateRange object should be created from the two dates. All the Date and DateRange objects should be printed out. Input and Output Consider the following input June 17, 1997 July 23, 1997 September 28, 1980 September 31, 1980 Mar. 2, 1980 Apr. 2, 1980 May 3, 1980 Nov 25, 1989 Dec 25, 1989 Jan 3, 1973 Note that the months might be writen in different ways. Also, note that there is one invalid date. This data should result in the following output: Date: June 17, 1997 Date: July 23, 1997 DateRange: Date: June 17, 1997 - Date: July 23, 1997 Date: September 28, 1980 Invalid Date Date: March 2, 1980 Date: April 2, 1980 DateRange: Date: March 2, 1980 - Date: April 2, 1980 Date: May 3, 1980 DateRange: Date: April 2, 1980 Date: May 3, 1980 Date: November 25, 1989 DateRange: Date: May 3, 1980 Date: November 25, 1989 Date: December 25, 1989 DateRange: Date: November 25, 1989Date: December 25, 1989 Date: January 3, 1973 Each of these lines should be the result of print statements like: System.out.println(date); System.out.println(daterange) where date and daterange are Date and DateRange objects, respectively
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started