Write a program names SortNamesGUI.java to perform the following tasks: 1. Desig
ID: 3855989 • Letter: W
Question
Write a program names SortNamesGUI.java to perform the following tasks: 1. Design a GUI application as shown in the document 2. There are three buttons in the GUI, Load File, Sort First Name, Sort 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 When the "Sort First Name" is clicked on, sort names according to their last name, then first name, display the sorted names in the third JTextArea 3. Handle exceptions. For example, file not found, or clicked on sort button before names are loaded.
Explanation / Answer
public class Main { private char[] VOWELS = new char[] {'a', 'e', 'i', 'o', 'u'}; public static void main(String[] args) { Main myMain = new Main(); for (String name : args) { if (myMain.inCharArr(myMain.VOWELS, name.charAt(0))) { System.out.println(name); } } } private boolean inCharArr(char[] arr, char cha) { boolean retval = false; for (char ch : arr) { if (ch == cha) { retval = true; } } return retval; } } import java.util.Scanner; public class Alphabetical_Order { public static void main(String[] args) { int n; String temp; Scanner s = new Scanner(System.in); System.out.print("Enter number of names you want to enter:"); n = s.nextInt(); String names[] = new String[n]; Scanner s1 = new Scanner(System.in); System.out.println("Enter all the names:"); for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.