Write a method that takes as input an array of integers and returns an integer. Pass the array of times to this method. The returned value should be the index corresponding to the person with the lowest time. You can then use the returned integer in main to index into the two arrays to grab both the name and the time. Print out the name and time corresponding to the returned index. You must use printf with formatting to format the output. Write a second method to find the index of the second-fastest time. The second method should use the first method to determine the best runner, and then loop through all values to find the second-best (second lowest) time. here what i got so far but im not sure if im on the right track some advice and feedback about my code would be helpful as well as similar example?
public class Marathon { public static void main(String[] arguments) {
String[] names = {
"Elena",
"Thomas",
"Hamilton",
"Suzie",
"Phil",
"Matt",
"Alex",
"Emma",
"John",
"James",
"Jane",
"Emily",
"Daniel",
"Neda",
"Aaron",
"Kate"
};
int[] times = {
341,
273,
278,
329,
445,
402,
388,
275,
243,
334,
412,
393,
299,
343,
317,
265
};
//int fastestIndex;
//int secondFastestIndex;
int i1 = fastestIndex(times); // i1 is the index of the fastest runner
// You need to use i1 to computer index of the second fastest runner
int i2 = secondFastestIndex(times, i1);
/*
//ADD YOUR CODE HERE TO PRINT THE RESULTS %2.2f\n for (int value : array)
//System.out.printf(" %d", value);
// System.out.printf(
"Effects of passing reference to entire array:%n"
"The values of the original array are:%n");
//System.out.printf("%-20s %4d\n", "spacing right", 45 );
*/
System.out.printf("Fastest Runner: %-20s %4d\n " + "spacing right", 45, i);
System.out.printf("Seconded Fastest Runner: %-20s %4d\n " + "spacing right", 45, i1);
}
//public static boolean determineIfPrime(int nm
//WRITE THE TWO METHODS, getFastestIndex AND getSecondFastestIndex, HERE
//The fastest runner is: John
public static boolean getFastestIndex(int[] times) {
for (int i = 0; i < times.length; i++) {
if (max < times[i]);
Index = i;
}
public static boolean getSecondFastestIndexFastestIndex(int[] times) {
for (int i1 = 0; i1 < times.length; i1++) {
if (max < times[i1]);
Index = i1;
}
}