Question
Write a program names SortNamesGUI.java to perform the following tasks: 1. Create a new data type named Person with two instance variables: String firstName and
Write a program names SortNamesGUI.java to perform the following tasks:
1. Create a new data type named Person with two instance variables: String firstName and String lastName 2. Write a method names sortNames as specified in the following header sortNames(Person[] arr, int type) this method should sort Person array based on the type: 1->sort based on last name 2->sort based on first name (both in alphabetic order)
3. Design a GUI application as shown in the document *******USE Scanner TO READ FILE INSTEAD OF BufferedReader******* (SEARCH BY FULL NAME I.E. "names.txt", not "names") 4. There are three buttons in the GUI, Load File, Sort First Name, Sort Last Name: the first line (N) in the data file indicates the number of names in the file, followed by N lines and each line in the data file represents a person name. Then sort and print names according to first and last name.
When the "Load File" button is clicked on, load names from the file then display the names in the first JTextArea When the "Sort First Name" is clicked on, sort names according to their first name, then last name, display the sorted names in the second JTextArea if two first names are the same, use last name to sort. When the "Sort Last Name" is clicked on, sort names according to their last name, then first name, display the sorted names in the third JTextArea 5. Handle exceptions. For example, file not found, or clicked on sort button before names are loaded.
THE TWO DATA FILES:
names.txt:
30 Stefanie Hooton Eleanora R. Blouin Alla Rundle Dia Gran Bertie Rathman Milly T. Edmond Libbie Filippini Ruthie Arnwine Sebastian Biggers Freida Ravencraft Angelia Bodkin Cicely Kandoll Phebe Nies Daphine Peil Yetta Syring Rudolf Hougland Leola Straube Josefa Starbird Donette Fullmer Bertie Mirelez Merry Rathman Cathern Diamond Rosalyn Arnwine Lillian Carew Lashanda Hendrick Stepanie Lindo Elda Ackermann Valeria Valdovinos Laurette Wedell Alla Gran
______________________
names2.txt:
8 Alla Rundle Dia Gran Bertie Rathman Milly T. Edmond Ruthie Arnwine Rosalyn Arnwine Lillian Carew Alla Gran
LI sorting Names Data ileLoad File Sort First Name Sort Last Name Data file Unsorted list Sorted based on first name Sorted based on last name
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