This error occurs when something is missing from the code. It is important to remember that a compiler may throw many error messages for one error. STATCALC JAVASCRIPT MISSING MAIN CLASS SOFTWAREUse 0 as a sentinel value (that is, stop reading numbers when the user enters 0).Compiler error messages are created when the Java software code is run through the compiler. calc new StatCalc( Read numbers from the user and add them to the dataset. Start by creating an object of type StatCalc: StatCalc calc // object to be used to process the data. You will need to add two new instance variables to keep track of the largest and smallest items that have been seen so far Test your new class by using it in a program to compute statistics for a set of non-zero numbers entered by the user. The getMax() method should return the largest of all the items that have been added to the dataset, and getMin() should return the smallest. The methods getMean() and getstandardDeviation() should only be called if the number of items is greater than zerdo Modify the current source code, StatCalc.java, to add instance methods getMax() and getMin(). getSum( ) 1s a function that returns the sum of all the items that have been added to the dataset calc.getMean() is a function that returns the average of all the items calc.getstandardDeviation) is a function that returns the standard deviation of the items Typically, all the data are added one after the other by calling the enter ) method over and over, as the data become available After all the data have been entered, any of the other methods can be called to get statistical information about the data. getCount() Is a function that returns the number of items that have been added to the dataset. If calc is a variable of type StatCalc, then the following instance methods are available calc.enter(item) where item is a number, adds the item to the dataset. You can read the source code for this class in the file StatCalc.java. I have written a little class called StatCalc that can be used to compute these statistics, as well as the sum of the items in the dataset and the number of items in the dataset. (A statistic is a number that summarizes some property of a set of data.) Common statistics include the mean (also known as the average) and the standard deviation (which tells how spread out the data are from the mean). Transcribed image text: Exercise 5.2: A common programming task is computing statistics of a set of numbers. Show transcribed image text Expert Answer StatCalc calc // Computes stats for numbers entered by user.ĭouble item // One number entered by the user. * Computes and display several statistics for a set of non-zero * The return value will be -infinity if no numbers have been entered. * Return the largest item that has been entered. * The return value will be infinity if no numbers have been entered. * Return the smallest item that has been entered. Return Math.sqrt( squareSum/count - mean*mean ) * Return the standard deviation of all the items that have been entered. * The return value is Double.NaN if no numbers have been entered. * Return the average of all the items that have been entered. * Return the sum of all the numbers that have been entered. * Return the number of items that have been entered into the dataset. * the numbers that have been added to the dataset using this method. Private double min = Double.POSITIVE_INFINITY // Smallest item seen. Private double max = Double.NEGATIVE_INFINITY // Largest item seen. Private double squareSum // The sum of the squares of all the items. Private double sum // The sum of all the items that have been entered. Private int count // Number of numbers that have been entered. * of items, the sum of the items, the average, the standard deviation, * statistics for the set of numbers that have been entered: The number Methods are provided to return the following Numbers are entered into the dataset using * An object of class StatCalc can be used to compute several simple statistics Changes from the original are shown in bold.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |