Menu

[Solved]Intro Java Level Question Far Need 3 Methods 1 Called Fastestrunner Takes Array Integers A Q37286419

This is an intro java level question what I have so far I need 3methods 1 called fastestRunner which takes an array of integers andand an array of Strings, and prints out the names and times( inminutes) of the first ,second and third runners in each year. Thismethod also returns the index corresponding to the person with thelowest time(the first runner) ​( This method should be called fromthe main method). Another called swapFirst​ that puts the name ofthe fastest runner at the beginning of the array.This method takesan array of Strings and an integer as its input and returns themodified array. ( This method should be called from thefatestRunner method.) And lastly one called ​compareTimes​ thatcompares the time in minutes of both years and returns an arraywith the record of the minutes improved or hindered back. Thismethod takes two arrays and returns an array. ( This method shouldbe called from the main method.) Im stuck and need help also pleaseexplain if possible

public class RaceProject {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
  
String runnersName [] = {“Emily”, “Simon”, “Paul”, “Aaron”, “Kate”,”Cindy”, “Ryan”, “James”, “Michael”, “Sara”, “Joseph”, “Juan”,”Brad”};
  
int runnersTime2017 [] = {357, 299, 432, 326, 275, 450, 265, 343,264, 308, 242, 377, 273};
  
int runnersTime2018 [] = {341, 307, 328, 283, 274, 359, 256, 323,269, 308, 249, 340, 238};
  
fastestRunner2017(runnersTime2017, runnersName);

}
  
public static int fastestRunner2017(int Array1[], StringNames[]){
  
int Smallest = Array1[0];
  
int secondSmallest = Smallest;

int thirdSmallest = secondSmallest;

for(int i=0;i<Array1.length;i++){
  
if(Array1[i] < Smallest){
  
thirdSmallest = secondSmallest;
  
secondSmallest = Smallest;
  
Smallest = Array1[i];
}

else if(secondSmallest > Array1[i] && Array1[i] >Smallest){

secondSmallest = Array1[i];
}
else if (thirdSmallest > Array1[i] && Array1[i] >secondSmallest){
  
thirdSmallest = Array1[i];
}

}

System.out.println(thirdSmallest + ” ” + secondSmallest + ” ” +Smallest);

return Smallest;
}

public static int swapFirst (int Array1 [], StringNames[]){
int Smallest = Array1[0];

for(int i=0;i<Array1.length;i++){
  
if(Array1[i] < Smallest){
  
Smallest = Array1[i];
}

}

System.out.println(Smallest);
return Smallest;

}
}

Expert Answer


Answer to This is an intro java level question what I have so far I need 3 methods 1 called fastestRunner which takes an array of … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *