Remember to do the NUMBER 5 1.Given an input file of dates represented as String
ID: 3577435 • Letter: R
Question
Remember to do the NUMBER 5
1.Given an input file of dates represented as Strings, read the dates from the file and display them in a GUI. The dates will be in the form yyyymmdd (such as 20161001 for October 1, 2016). The GUI should have a GridLayout with one row and two columns. The left column should display the dates in the order read from the file, and the right column should display the dates in sorted order (using Selection Sort).
2.The Strings representing the dates may be compared using the compareTo method in class String. As you are reading the dates you should check that the value read in is legal (8 digits), and if it is not, print it to the console and do not put it in the array of dates.
The input file
Each line of the input file may contain several dates separated by commas. You will need to use a StringTokenizer to separate out the individual dates. So, an example of the input file would be:
3.Create a class called Date212 to represent a date. It will store the year, month and day as integers (not as a String), so you will need three private instance variables. Two constructors should be provided, one that takes three integer parameters, and one that takes a String . The constructor with the String parameter should validate the parameter. and then use the substring method of class String to pull out the month, day and year, parse them as integers and call the three-argument constructor. The three-argument constructor should make sure that the month and day values are legal. To call another constructor from within a constructor, use the method this:
public Date212 (String d) { // the one-argument constructor
...
... this(year,month,day) //invokesthethree-argumentconstructor.
}
List of Dates
Create a class called DateNode which has fields for the data (a Date212) and next (DateNode) instance variables. Include a one-argument constructor which takes a Date as a parameter. (For hints, see the PowerPoint on "Static vs. Dynamic Structures”.)
The instance variables should have protected access. There will not be any get and set methods for the two instance variables.
Create linked list class called DateList. This should be a linked list with head node as described in lecture. Modify it so that the data type in the nodes is Date212. The no-argument constructor should create an empty list with first and last pointing to an empty head node, and length equal to zero./////
Include two methods in class DateList: append and insert. The append method will add the new node to the end of the list; the insert method will add the node in the proper position to keep the list sorted in order by date.
Instantiate two linked lists, and for every date read from the file, add it to the first list using append, and to the second list using insert. You will end up with the first list having the dates from the input file in the order they were read, and in the second list the dates will be in sorted order. Display the unsorted and sorted dates in the GUI.
ToString() for Class Date212.
Create a toString method in lass Date212 the will return the date in the form mm/dd/yyyy. Use this method to display the dates in the GUI.
1.Create a class hierarchy which has an abstract class called DateList (the same class as in project 2 but it is abstract). This class should have two subclasses: UnsortedDateList and SortedDateList, each having a method called add. In the UnsortedDateList the method add will add to the end of the list (append), and in the SortedDateList it will do an insert. So now, rather than in project 2 where you used two of the same kind of list (DateList) you will use one unsorted list and one sorted list.
2.Create a new exception called IllegalDate212Exception by extending lllegalArgumentException.
3.When you create a new Date212 from a String read from the input file, catch any exceptions thrown by the constructor and print the offending string to the console along with the message from the Exception.
4.Add a File menu to your GUI which has menu items for Open and Quit. You should now be able to select an input file using the GUI.
5.Use a TreeMap to sort the dates that are to be displayed, as usual, in the right column of the GridLayout. All the code you need is in the PowerPoint on TreeMaps. You will need to create a Comparator for the class Date212.
Submitting the Project.
You should now have at least the following files to submit for this project:
Explanation / Answer
Scanner sc = new Scanner(System.in);
int TeamAScore = zero, TeamBScore = 0;
int currentQuestionTeam = 0;
String[] queries = new String[6];
String[] answers = new String[6];
System.out.println("Welcome Team A and Team B i am your host Steve Harvey");
System.out.println("I are asking you some question and you'll receive one purpose for every answer ");
System.out.println("you should sort your answer in character type alternative wise you will not get the answer");
System.out.println("right. therefore lets get started!");
questions[0] = "Name forms of beverages folks drink:";
answers[0] ="Soda","Fruit juice","Tea";
questions[1] ="Name one thing folks gnaw at breakfeast:";
answers[1] ="eggs","toast","bacon ";
questions[2] ="Place wherever you see scores of joggers?:";
answers[2] ="park","mountain","neighborhood";
questions[3]="Something folks save?:";
answers[3]="money", "photos","coupons";
questions[4]="Why a baby may well be cranky?:";
answers[4]="tired","hunger","burp";
questions[5]="Something tiny that scares childern and adults?:";
answers[5]="spiders","mice","rats";
for(int i=0;i< 6;i++)
}
}else
}
}
}
currentQuestionTeam = 1;
for(int k=1;k<=3;k++)
}
}
else
}
}
}
currentQuestionTeam = 0;
}
System.out.println("Team A score: "+TeamAScore);
System.out.println("Team B score: "+TeamBScore);
if(TeamAScore > TeamBScore)