Question: Design and implement a Java method, named findIndex ( . . . ) , in a separate class ( and separate file ) named IndexOfLargest.

Design and implement a Java method, named findIndex(...), in a separate class (and separate file) named IndexOfLargest. The method takes a single-dimensional array of integer values as a parameter, and it returns the index of the largest value in the array. If the largest value appears more than once, the method returns the smallest index of that value (i.e., index of first occurrence of that value). Notice that array indexing in Java starts with 0. Next, write a test program in a separate file, named TestIndexOfLargest, such that the main method asks the user to enter 10 integer values into an array, then call method findIndex(...) in class IndexOfLargest to determine and display the index of the first largest value in the array. Design the main method such that it allows the user to re-run the program with different sets of inputs (as in previous assignments, using a sentinel loop). Document your code and organize and space the outputs properly using escape characters as shown below. The sample test data below shows only the output labels. Please DO NOT read user inputs as String type. The sample tests below DO NOT show the input prompts, just the outputs. Again, the user may enter all numbers on one line or one per line. Make sure your code displays the outputs following the test data format. First test: You entered these values: 1523-1312119025-179090 Index of largest value: 5 Second test: You entered these values: 5678123-11312211-50056781751100 Index of largest value: 0 Third test: You entered these values: -15-3-13-62-15-51-125-117-15-10 Index of largest value: 1 Fourth test: You entered these values: 125-3-13-62-11541-125-1175551300 Index of largest value: 9

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!