Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class Deviation {
- public static void main(String[] args) {
- int participants;
- double [] arrSeconds = new double[10] ;
- int i = 0;
- double fastest = 50000 ;
- double slowest =0;
- Scanner scan = new Scanner(System.in);
- System.out.print("Брой на участниците :");
- participants = scan.nextInt();
- if( participants > 10){
- System.out.print("Моля въведете до 10 участника. Въведете наново :");
- participants = scan.nextInt();
- }
- while (i < participants){
- System.out.print("Участник номер " + i + " секунди :");
- arrSeconds[i]= scan.nextDouble();
- i++;
- }
- System.out.println(Arrays.toString(arrSeconds));
- double total = 0;
- for( int j = 0 ; j <participants ; j++){
- if(arrSeconds[j]>slowest){
- slowest = arrSeconds[j];
- }
- if(arrSeconds[j]<fastest && arrSeconds[j]!=0){
- fastest = arrSeconds[j];
- }
- total +=arrSeconds[j];
- }
- double averageSeconds = total/participants;
- System.out.println("Най-бързо време : " + fastest);
- System.out.println("Най-бавно време : " + slowest);
- System.out.println("Средно Аретм. : " + averageSeconds);
- double mean = total/participants;
- double preVariance =0 ;
- for (int j =0 ; j < participants; j++){
- preVariance+=Math.pow(arrSeconds[j] - mean , 2);
- }
- double variance= preVariance/(participants -1);
- double standartDeviation = Math.sqrt(variance);
- System.out.println("Standart Deviation : " + standartDeviation);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement