Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. In Eclipse, please create a project with a project name of the form hw9LastFirst substituting your last name for Last and your first name
1. In Eclipse, please create a project with a project name of the form hw9LastFirst substituting your last name for "Last" and your first name for "First." For example, someone named John Smith would name his project hw9SmithJohn. 2. (10 pts) Write a program which uses a two-dimensional array to store the first and last names of the 12 most recent U.S presidents. The 12 most recent U.S. presidents are listed below. (Note that two were named George Bush.) Dwight Eisenhower John Kennedy Lyndon Johnson Richard Nixon Gerald Ford James Carter Ronald Reagan George Bush William Clinton George Bush Barack Obama Donald Trump The first names should be stored in the first column (indexed by 0) and the last names should be stored in the second column indexed by 1). For example, if the array is called names then names[0, 0] would be "Dwight", names[0, 1] would be Eisenhower", names1, 0] would be "John", names[1, 1] would be "Kennedy", names[2,0] would be "Lyndon", names[2, I] would be "Johnson", ete. Write a method which accepts a reference to a two-dimensional array" of Strings and sorts the array by the second column (i.e. by last name in this example). If two rows have the same valuc for the second column (as in the case of the two presidents named George Bush), the method should attempt to use the first column to break the tie if possible (although in the case of the two presidents named George Bush, there will still be a tic). Write another method which accepts the first and last name of a president for which to search. The method should use a binary search to search the sorted array of names for the president entered by the user. The method should return the index of the row where a match was found or-1 if no match was found Write a method which accepts a reference to a "two-dimensional array of Strings and prints the clements of the array with each row of the array printed on a separate line, and each column of the array separated by a space. Write a main method which calls your "helper" methods to print the clements of the array before and after sorting the array. Once the array has been sorted, you main method should allow the user to enter the first and last name of a president to search for and then call your binary search method and display the results of the search. Do not call any methods that come with Java which operate on entire arrays
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