Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago