Write a class called StatisticsCalculator that calculates the mean (average) and
ID: 3646156 • Letter: W
Question
Write a class called StatisticsCalculator that calculates the mean (average) and standard deviation for a set of integer values entered by the user.Assume all input values will be valid integers (you don't have to test for validity). Your program should:
prompt the user for the number of values, n. (n must be 2 or greater!, assume it will be)
create an array to store the values.
prompt the user for each value and store it in the array.
calculate and output the mean of the values (x?).
calculate and output the standard deviation of the values using the formula below:
Here is a sample execution of the program:
csc% java StatisticsCalculator
How many values?: 4
Enter value 1: 4
Enter value 2: 5
Enter value 3: 8
Enter value 4: 9
Mean: 6.50
Standard Deviation: 2.38
Be sure to Javadoc your program!!
Explanation / Answer
Perfect code here... import java.io.*; import java.lang.*; class StatisticsCalculator { public static void main(String args[]) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int i=0,size=0,s; s=size+1; float sum=0,mean=0; double std_deviation=0; System.out.println("Enter number of values:"); try{ i=Integer.parseInt(br.readLine()); }catch(Exception e) { } int array[]=new int[i]; while(i>0) { System.out.println("Enter "+s+" value"); try{ array[size++]=Integer.parseInt(br.readLine()); }catch(Exception e) { } i--; s++; } for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.