Answered! Please help me write a psuedocode for the followign question… Design a program that reads an arbitrary number of runners…

Please help me write a psuedocode for the followign question…

Design a program that reads an arbitrary number of runners’ names and their times and outputs the name of the runner or runners with the fastest time.

Design one module that reads and returns a runner’s name and time. What are this module’s parameters?

Design a module that reads all the runners’ names and times and stores the names and times in parallel arrays. What are this module’s parameters and what does it return?

Design a module that finds and returns the fastest time. What are this module’s parameter or parameters?

Design a module that returns the name or names of the players with the fastest time. What are this module’s parameters?

Design a module that displays the winning runners’ names and their time.

Use parameters and returns in all of your modules.

Expert Answer

import java.util.Scanner;
public class Runners {
static Scanner sc=new Scanner(System.in);
// static String names[]=null;
// static int times[];
Runners(){
System.out.println(“enter number of Runners:”);
int num=sc.nextInt();
String[] names=new String[num];
int[] times=new int[num];
storedatainarray(names,times,num);
System.out.println(“enter name to display runners data:”);
String name=sc.next();
displayrunnersdata(names,times,name);
int fast=returnfastest(times);
System.out.println(“fastest time:”+fast);
String fastname_time=return_fastest_name_time(times,names);
System.out.println(“fastest name and time of runner:”+fastname_time);
winningrunner(names,times,55);
}
public static void storedatainarray(String[] names,int[] times,int num){
// module that reads all the runners’ names and times and
//stores the names and times in parallel arrays.
//input paramters to this module is names array and times array and limit of runners
//it return void..(nothing)
for(int i=0;i<num;i++){
System.out.println(“enter name of player to store in array:”);
String name=sc.next();
System.out.println(“enter times of player to store in array:”);
int time=sc.nextInt();
names[i]=name;
times[i]=time;

}

}
public static void displayrunnersdata(String[] names,int[] times,String name){

/*module that reads and returns a runner’s name
and time…it takes String array and int array and string name as input parametr and
returns name and time of that particular runner*/
for(int i=0;i<names.length;i++){
if(names[i].equalsIgnoreCase(name))
System.out.println(“runner data=”+names[i]+” “+times[i]);
}
}
public static int returnfastest(int times[]){
/*module that finds and returns the fastest time.
* it takes int times array as input parameter
* and return integer type fast as return type
*/
int fast=0;
for(int i=0;i<times.length;i++){
if(times[i]>fast){
fast=times[i];
}

}
return fast;
}
public static String return_fastest_name_time(int times[],String names[]){

/*module that returns the name or names of the
* players with the fastest time.it takes integer times array
* and string names array and returns a string of name and time
* of fastest runner
*/
int fast=0;
String name=””;
for(int i=0;i<times.length;i++){
if(times[i]>fast){
fast=times[i];
name=names[i];
}

}
return name+” “+fast;
}
public static void winningrunner(String names[],int times[],int crosstime){
/*module that displays the winning runners’ names and their time.
* here we taken string names array and integer times array and
* a integer type variable with times holds.whose time is greater or
* equal to cross time they are declared as winners
*
*/
for(int i=0;i<times.length;i++){
if(times[i]>=crosstime){
System.out.println(names[i]+” “+times[i]);
}
}

}
}

mainclass:
import java.util.*;
public class Runner {
static Scanner sc=new Scanner(System.in);

public static void main(String[] args) {
// TODO Auto-generated method stub

Runners r=new Runners();

}
}
output:
enter number of Runners:
5
enter name of player to store in array:
swarup
enter times of player to store in array:
99
enter name of player to store in array:
ale
enter times of player to store in array:
98
enter name of player to store in array:
mahe
enter times of player to store in array:
45
enter name of player to store in array:
sravan
enter times of player to store in array:
56
enter name of player to store in array:
john
enter times of player to store in array:
78
enter name to display runners data:
john
runner data=john 78
fastest time:99
fastest name and time of runner:swarup 99
swarup 99
ale 98
sravan 56
john 78

Still stressed from student homework?
Get quality assistance from academic writers!