Question: Question: Using the StatCalc class, write a program that calculates and then displays as output to the console, the following statistics against the set of

Question:

Using the StatCalc class, write a program that calculates and then displays as output to the console, the following statistics against the set of numbers given below.

Statistics that must be calculated: Count Quantity of numbers in the data set. Mean The mean or average of the numbers in the data set. Standard Deviation The measure of variance (or dispersion) from the mean.

The set of numbers that you must use is as follows: 5 7 12 23 3 2 8 14 10 5 9 13

You must create a program with a main method that defines the StatCalc class and instantiates an instance of StatCalc called myStatCalc.

Your program should instantiate the instance of the StatCalc using a statement similar to the following:

StatCalc myStatCalc;

myStatCalc = new StatCalc();

Here is what I have so far:

Question: Using the StatCalc class, write a program that calculates and then

package calctest; public class CalcTest { public static void main(String[] args) { StatCalc myStatCalc; myStatCalc = new StatCalc(); int intArray[] = { 5, 7, 12, 23, 3, 2, 8, 14, 10, 5, 9, 13 }; for (int i : intArray) System.out.println("The number of values in the data set is: " + myStatCalc.getCount()); System.out.println("The Mean of the data set is: " + myStatCalc.getMean()); System.out.println("The Standard Deviation of the data set is: " + myStatCalc.getStandardDeviation()); } }

But I keep getting this error:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: calctest.StatCalc

at calctest.CalcTest.main(CalcTest.java:5)

C:\NetBeans\Cache\8.2\executor-snippets un.xml:53: Java returned: 1

BUILD FAILED (total time: 0 seconds)

What am I doing wrong? I do have the StatCalc Class:

/* * An object of class StatCalc can be used to compute several simple statistics * for a set of numbers. Numbers are entered into the dataset using * the enter(double) method. Methods are provided to return the following * statistics for the set of numbers that have been entered: The number * of items, the sum of the items, the average, and the standard deviation */ public class StatCalc { private int count; // Number of numbers that have been entered. private double sum; // The sum of all the items that have been entered. private double squareSum; // The sum of the squares of all the items. /** * Add a number to the dataset. The statistics will be computed for all * the numbers that have been added to the dataset using this method. */ public void enter(double num) { count++; sum += num; squareSum += num*num; } /** * Return the number of items that have been entered into the dataset. */ public int getCount() { return count; } /** * Return the sum of all the numbers that have been entered. */ public double getSum() { return sum; } /** * Return the average of all the items that have been entered. * The return value is Double.NaN if no numbers have been entered. */ public double getMean() { return sum / count; } /** * Return the standard deviation of all the items that have been entered. * The return value is Double.NaN if no numbers have been entered. */ public double getStandardDeviation() { double mean = getMean(); return Math.sqrt( squareSum/count - mean*mean ); } } // end class StatCalc

CalcTest - NetBeans IDE 8.2 File Edit View Navigate Source Refactor Run Debug Profile Team Tools Window Help Search (Ctri-+I) | Files CalcTest Start Page EDCalcTest.javaStatCalc.java Source | History servi reG1,1q!?BI106] Source Packages -B calctest package calctest: 2 public class CalcTest CalcTest.java3 public static void main(String ] args) StatCalc.java Test Packages Libraries Test Libraries Statcalc myStatCalc; myStatCalcnew Statcalc 7int intArray-5, 7, 12, 23, 3, 2, 8, 14, 10, 5, 9, 13 or (int i : intArray) Source Packages 9 System.out.printin ("The number of values in the data set is: myStatCalc.getcount)) SubRoutinePalndn System.out.printin ("The Mean of the data set is:myStatcalc.getMean o) B-firstsubroutines 11System.out.println ("The Standard Deviation of the data set is: "+ myStatCalc.getstandardDeviation)) 11 12 13 14 Navigator Members CalcTst main(String args) Output-CalcTest (run) Exception in thread "main" java.lang.RuntimeException: Uncompilable source codeErroneous tree type: calcteat.StatCalc at calctest.CalcTest.main CalcTest.java:5) C:Users Wiggincton AppData Local NetBeans Cache8.lexecutor-snippetsirun. xml:53 Java returned:1 BUILD FAILED (total time: O seconds) 14:2 INS

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!