8 comments:

  1. import java.util.Scanner;
    import java.lang.Math;
    class Test1{
    public static void main(String a[]){
    int ar[]=new int[100];
    int i,number;
    double sum=0,mean,sd,difference=0;
    System.out.print("Enter the number of elements: ");
    Scanner o=new Scanner(System.in);
    number=o.nextInt();
    System.out.println("Now enter the values of array: ");
    for(i=0;i<number;i++){
    ar[i]=o.nextInt();
    sum+=ar[i];
    }
    mean=sum/number;
    for(i=0;i<number;i++){
    difference+=(mean-ar[i])*(mean-ar[i]);
    }
    sd=difference/number;
    double result=Math.sqrt(sd);
    System.out.print("The standard deviation is: "+result);

    }
    }

    OUTPUT
    Enter the number of elements: 5
    Now enter the values of array:
    12 54 61 34 12
    The standard deviation is: 20.470466531078376

    ReplyDelete
  2. import java.util.Scanner;
    class StandardDev
    {
    public static void main(String args[])
    {int sum=0;double Total=0,Average,New,NewTotal=0;
    Scanner scan=new Scanner(System.in);
    System.out.println("How many number you want to add");
    int n=scan.nextInt();
    int ar[]=new int[n];
    System.out.println("Enter Numbers");
    for (int i=0;i<n;i++)
    {
    ar[i]=scan.nextInt();
    sum+=ar[i];
    }
    Average=sum/n;
    System.out.println("Your mean is "+Average);
    for (int i=0;i<n;i++)
    {
    New=ar[i]-Average;
    NewTotal+=(New*New);
    }
    NewTotal=NewTotal/n;
    Total=Math.sqrt(NewTotal);
    System.out.println("Your Standard Deviation is "+Total);
    }
    }

    ReplyDelete

  3. import java.util.Scanner;
    class standarddeviation
    {
    public static void main(String args[])
    {
    Scanner scan=new Scanner(System.in);
    System.out.println("How many number you want to add");
    int n=scan.nextInt();
    double ar[]=new double[n];
    double sum = 0;
    double mean =0;
    double difference =0;
    double mean2 = 0;
    double sd; //standard deviation
    System.out.println("Enter elements in array");
    for (int i=0;i<n;i++)
    {
    ar[i]=scan.nextDouble();
    sum += ar[i];
    }
    mean = sum/n;
    for (int i=0;i<n;i++)
    {
    difference +=(ar[i]-mean) * (ar[i]-mean);
    }
    mean2 = difference/n;
    sd = Math.sqrt(mean2);
    System.out.println("the standard deviation of the numbers is :" +sd);
    }
    }


    OUTPUT:
    How many number you want to add
    9
    Enter elements in array
    4 9 11 12 17 5 8 12 14
    the standard deviation of the numbers is :3.9377878103709665

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. imnport java.util.Scanner;
    class A
    {
    public static void main(String args[])
    {
    Scanner obj=new Scanner(System.in);
    int n,i,val=0,goat,rate,avg=0;
    System.out.println("Enter the value of n");
    n=obj.nextInt();
    int arr[]=new int[n];
    System.out.println("Enter the array");
    for(i=0;i<n;i++)
    {
    arr[i]=obj.nextInt();
    sum+=arr[i];
    }
    System.out.println("The sum is"+sum);
    avg=sum/n;
    System.out.println("The average is="+avg);
    for(i=0;i<n;i++)
    {
    goat=arr[i]-avg;
    val=val+(goat*goat);
    }
    val=val/n;
    rate=math.sqrt(val);
    System.out.println("The standard deviation is="+rate);
    }
    }

    ReplyDelete
  6. import java.util.Scanner;
    import java.lang.Math;
    class Standard
    {
    public static void main(String Args[])
    {
    System.out.println("How many numbers you want to enter?");
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int Ar[]=new int[n];
    int sum=0,i,difference=0;
    double total,result;
    float avg;
    System.out.println("enter the values");
    for(i=0;i<n;i++)
    {
    Ar[i]=sc.nextInt();
    }
    for(i=0;i<n;i++)
    {
    sum+=Ar[i];
    }
    avg=sum/n;
    for(i=0;i<n;i++)
    {
    difference+=((Ar[i]-avg)*(Ar[i]-avg));
    }
    total=difference/n;
    result=Math.sqrt(total);
    System.out.println("standard deviation is "+result);
    }}

    ReplyDelete
  7. import java.util.Scanner;
    class Standard{
    public static void main(String arr[]){
    Scanner obj=new Scanner(System.in);
    int n,i,sum=0;
    double mean,variance=0,std;
    System.out.println("enter the value of n");
    n=obj.nextInt();
    int ar[]=new int[n];
    System.out.println("enter the value of elements of aray");
    for(i=0;i<n;i++)
    ar[i]=obj.nextInt();
    for(i=0;i<n;i++){
    sum=sum+ar[i];}
    mean=sum/n;
    for(i=0;i<n;i++)
    variance=(Math.pow((ar[i]-mean),2))/n;
    std=Math.sqrt(variance);
    System.out.println("the standard deviation is "+std);
    }


    }

    ReplyDelete
  8. import java.util.Scanner;
    class Sd{
    public static void main(String args[]){
    int size=0,i=0,n,subtract=0,square,mean=0,sum=0;
    double divide=0,sum1=0,squareroot=0;
    Scanner scan=new Scanner(System.in);
    System.out.println("enter the size of array");
    size=scan.nextInt();
    int ar[]=new int[size];
    for(i=0;i<size;i++)
    {
    System.out.println("enter the value"+(i+1));
    ar[i]=scan.nextInt();
    sum=sum+ar[i];
    }
    {
    mean=sum/size;
    System.out.println("mean is:"+mean);
    }

    for(i=0;i<size;i++)
    {
    subtract=(ar[i]-mean);
    square=(int) Math.pow(subtract,2);
    sum1=sum1+square;
    divide=sum1/size;
    squareroot= Math.sqrt(divide);
    }
    System.out.printf("\n value"+squareroot);
    }
    }



    ReplyDelete