Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

our first a T 2. ?10 pts) wrte a program whichues i two-dimensional array to store the nmand last names of the i2 most recent

image text in transcribed

our first a T 2. ?10 pts) wrte a program whichues i two-dimensional array to store the nmand last names of the i2 most recent us presidents. The 12 most rocet U.S presidents are listed below, (Note that two were named George Bush) Dwight Eisenhower John Kennedy L yndoe Johnson Richard Nixon Gerald Ford James Carter Ronald Reagan George B William Clinton George Bush Rarack Oleama Donald Tnump The first names should be stored in the first column( indexed by 0} and the last names should be stored in the second column tindesed by T). For example, if the aray is called names then names|O, O1 would be "Dwight",aes10, 11 woul be Fisenhower", names! I. ? vould be "John", names(l, 1] would be ..Kennedy . narrest2,0[would be "Lyndon'", names(2, 1 woukf be Johnson etc Write a method which accepes a reference to a two-dimensional array of Strings and sorts the array by the second column ie by last name in this examplex it two rows have the same value for the second column tas in the case of the two presidents named George Bush), the method should attempt to use the tirst column to break the tie if possible (although in the ease of the two presidents named Creorge Bush, there will still be a tie) Write anocher 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 shoald return the indes of the tow 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 elements of the array with cach 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 elements of the array before and after sorting the urray. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions