I need to display some result in command line or terminal pl

I need to display some result in command line or terminal.

please help me ,,

Solution

//StdDev.java
/*
* Usage of class StdDev
* Sample run1:
* java StdDev 1.2 3.4 5.6 ctrl-z(press enter)
* Average [3] is 3.4
* StdDev [3] is 1.7962924780409972
*
* Sample run2:
* java StdDev 1.2 xxx ctrl-z(press enter)
* Usage : StdDev [n0 n1 n2....n]
*
* */
public class StdDev
{  
   static double[] arr;
   static int N;
   public static void main(String[] args) {
       if(args.length==0)
       {
           System.out.println(\"Usage: StdDev [n0 n1 n2...n]\");          
       }
       else
       {
           int N=args.length;          
           arr=new double[N];
           try
           {

               for (int i = 0; i < N; i++)               
                   arr[i]=Double.parseDouble(args[i]);                                  

               System.out.println(\"Average [\"+N+\"] is \"+average(arr, N));
               System.out.println(\"StdDev [\"+N+\"] is \"+getStdDev(arr, N));

           } catch (Exception e) {
               System.out.println(\"Usage: StdDev [n0 n1 n2...n]\");
           }
       }
   }

   //Method that takes data and size and returns the average of data
   public static double average(double[] data, int size)
   {
       double total=0;

       for (int i = 0; i < data.length; i++)
       {
           total+=data[i];
       }      
       return total/data.length;
   }

   //Method that takes data and size and returns variance
   public static double getStdDev(double[] data, int size)
   {
       //calling average to find mean
       double mean = average(data, N);
       //set t=0
       double t = 0;
       for(double a :data)
           t += (a-mean)*(a-mean);
       //calculate variable
       double variance=t/size;
       //calculate sqare root of variance
       return Math.sqrt(variance);
   }
}

Sample Output:

Average [3] is 3.033333333333333
StdDev [3] is 1.3719410418171119

I need to display some result in command line or terminal. please help me ,,Solution//StdDev.java /* * Usage of class StdDev * Sample run1: * java StdDev 1.2 3.
I need to display some result in command line or terminal. please help me ,,Solution//StdDev.java /* * Usage of class StdDev * Sample run1: * java StdDev 1.2 3.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site