Question: Write a program names SortNames.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 SortNames.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->srot based on last name 2->sort based on first name (both in alphabetic order) 3. Write an application named SortNameApp.java that read names from the data file: 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.
*******USE Scanner input=new Scanner(new File(args[0])); TO READ FILE INSTEAD OF BufferedReader*******
names.txt:
30 Stefanie Hooton Eleanora R. Blouin Alla Rundle Milly T. Edmond Libbie Filippini Rosalyn Chairez Sebastian Biggers Freida Ravencraft Angelia Bodkin Cicely Kandoll Phebe Nies Daphine Peil Camie KK Vieyra Yetta Syring Rudolf Hougland Leola Straube Josefa Starbird Donette Fullmer Bertie Mirelez Merry Rathman Cathern Diamond Ruthie Arnwine Lillian Carew Lashanda Hendrick Ignacia Kierstead Stepanie Lindo Elda Ackermann Valeria Valdovinos Laurette Wedell Dia Gran
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
