Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need this in Java. Use buffered reader inn stead of scanner class please: Your s

ID: 3864476 • Letter: N

Question

Need this in Java. Use buffered reader inn stead of scanner class please:

Your software company has been requested to provide a prototype program performing the simple statistical evaluations. You will need to implement a main program that reads the values into the array (or you could write another method to read them in), then call each of the various methods that you will convert from your previous programming project. The following methods comprise the StatPackage.

The function specifications are as follows:

Your StatPackage will accept up to 500 values as input.

Numerical values will be printed with two significant digits to the right of the decimal point.

The program will contain the following functions:

static double calcMean (int scores [], count) calculates the mean value for the values stored in the array scores mean is essentially the same as the average.

static double calcMedian (int scores [], count) calculates the median value for the values stored in the array scores median is the is middle value of the stored values.

static double calcVariance (int scores [], count) calculates the variance value for the values stored in the array scores Variance is determined by the formula:

static double calcStdDev (double variance) calculates the standard deviation value for the values stored in the array scores. Standard deviation is the square root of the variance.

Your software company has been requested to provide a prototype program perform the simple statistical evaluations. You will need to implement a main program that reads the values into the array (or you ing could write another method to read them in). the call each of the various methods that you will convert from your previous programming project. The following methods comprise the StatPackage n The function specifications are as follows: 1. Your StatPackage will accept up to 500 values as input. 2. Numer cal values will be printed with two significant digits to the right of the decimal point The program will contain he following functions 1. static double calcMean (int scores D, cont calculates the mean value for the values stored in the array scores mean is essentially the same as the average 2. static double calcMediam (int scores D, count calculates the median value for the values stored in the amay scores median is the is middle value of the stored values. 3. static double caicVamiamce (int scores U, count calculates the variance value for the values stored in the array scores Variance is determined by the fom the sum of the square of the values count square of the sum of the values square of the count 4. static double calcStaDev (double ance) calculates the standard deviation value for the values stored in the array scores. Standard deviation is the square root of the va

Explanation / Answer

MeanMedianVarStd.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class MeanMedianVarStd {

public static void main(String[] args) {
  
   //Creating an integer array of size 300
       int scores[]=new int[300];
      
       //Declaring variables
       int num;
       int count=0;
       String input;
      
       //This is used to read the inputs entered by the user
       BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      
       /* This loop continues to read the values
       * entered by the user until the user enters -1
       */
           try {
               while(count<300)
               {
               //Getting the scores entered by the user
                   System.out.print("Enter score "+(count+1)+":");
                   input = reader.readLine();
               num = Integer.parseInt(input);
                 
               /* if the user entered value is not -1
               * then populate those values into an scores array
               * */
               if(num==-1)
                   break;
               scores[count]=num;
               count++;   
               }
              
           } catch (IOException e) {
              
               System.out.println("Exception :"+e);
           }

           //Displaying the elements in the array
           System.out.println("Displaying the elements in the array :");
           for(int i=0;i<count;i++)
           {
               System.out.print(scores[i]+" ");
               if((i+1)%10==0)
                   System.out.println();
           }
          
           //calling the methods
           double mean=calcMean (scores, count) ;
           double median=calcMedian (scores, count);
           double variance =calcVariance (scores, count);
           double std=calcStdDev (variance);
          
           //Displaying the output
           System.out.printf(" Mean :%.2f",mean);
           System.out.printf(" Medin :%.2f",median);
           System.out.printf(" Variance :%.2f",variance);
           System.out.printf(" Standard Deviation :%.2f",std);
          
  

   }

//this method is used to calculate the standard deviation
   private static double calcStdDev(double variance) {
  
       return Math.sqrt(variance);
   }

   //this method is used to calculate the variance
   private static double calcVariance(int[] scores, int count) {
      
       //Declaring local variables
   double sum1=0.0,mean;
  
   //calculating the sum of nos[] array elements
   for(int i=0;i<count;i++)
   {
   //calculating the sum
   sum1+=scores[i];
   }
  
   //calculating the average
   mean=sum1/count;
  
   double variance,std_dev,sum=0.0;
   for(int i=0;i<count;i++)
   {
   sum+=Math.pow(scores[i]-mean,2);
   }
   //calculating the standard deviation of nos[] array
   variance=(double)sum/(count-1);

       return variance;
   }

   //this method is used to find the median value
   private static double calcMedian(int[] scores, int count) {
int temp,middle;
double median;

for (int i = 0; i < count; i++)
{
for (int j = i + 1; j < count; j++)
{
if (scores[i] > scores[j])
{
temp = scores[i];
scores[i] = scores[j];
scores[j] = temp;
}
}
}
  
if(count%2==0)
middle = count/2;
else
middle=(count+1)/2;
  
median=(double)(scores[middle - 1] + scores[middle]) / 2.0;

       return median;
   }

   //This method is used to calculate the mean
   private static double calcMean(int[] scores, int count) {
   //Declaring local variables
   double sum=0.0,mean;
  
   //calculating the sum of nos[] array elements
   for(int i=0;i<count;i++)
   {
   //calculating the sum
   sum+=scores[i];
   }
  
   //calculating the average
   mean=sum/count;
   return mean;

   }

}

__________________

Output:

Enter score 1:98
Enter score 2:93
Enter score 3:72
Enter score 4:86
Enter score 5:99
Enter score 6:61
Enter score 7:89
Enter score 8:77
Enter score 9:91
Enter score 10:73
Enter score 11:-1
Displaying the elements in the array :
98 93 72 86 99 61 89 77 91 73

Mean :83.90
Medin :87.50
Variance :158.10
Standard Deviation :12.57

_________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote