WAP in java to accept a name of athlete and the time clocked by him to cover 100 metres in a competition. The program should ask for continuation. At last display the name of the athlete who has secured the top position. (Use while loop)
Plz answer fast...
Answers
Answered by
1
Answer:
import java.io.*;
import java.util.*;
class Athlete
{
public static void main(String args[]) throws IOException
{
int x = 0;
Scanner scanner = new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i = 0; i < 5; i++)
{
System.out.print("Enter the name of the athlete " + (i+1) + ":");
String name = br.readLine();
System.out.print("Enter the time taken to complete 100m:");
int time = scanner.nextInt();
list.add(time);
}
int max = Collections.max(list);
System.out.println("The fastest time is:" + max);
}
}
Explanation:
Similar questions