Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class Competition {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println();
- int a = scanner.nextInt();
- double arr[] = new double[a];
- double sum=0;
- double fastes = 0;
- double ave = 0;
- double slowest = 0;
- double sdl=0;
- double sd=0;
- for (int i = 0; i < a; i++) {
- System.out.println("Enter the time of the the competitors");
- arr[i] = scanner.nextDouble();
- if (slowest < arr[i]) {
- slowest = arr[i];
- }
- if (arr[i] < arr[0]) {
- fastes = arr[i];
- } else {
- fastes = arr[0];
- }
- sum += arr[i];
- }
- ave = sum / arr.length;
- for (int i = 0; i < a; i++) {
- sdl=sum*(Math.pow((arr[i]-ave),2));
- sd=Math.sqrt(sdl/a);
- }
- System.out.println(Arrays.toString(arr));
- System.out.println("The fastest one is: " + fastes);
- System.out.println("The slowest one is: " + slowest);
- System.out.println("The average speed is: " + ave);
- System.out.println("The standard deviation is: " + sd);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement