Question: public class SimpleStats { public static void main(String[] args) { StatCalc calc; calc = new StatCalc(); double item; System.out.println(Enter your numbers:); System.out.println(); do { System.out.println(?

public class SimpleStats { public static void main(String[] args) { StatCalc calc; calc = new StatCalc(); double item; System.out.println("Enter your numbers:"); System.out.println(); do { System.out.println("? ");

item = TextIO.getlnDouble(); if (item != 0) calc.enter(item); } while ( item != 0 ); System.out.println(" Minimum: " + calc.getMin()); System.out.println(" Maximum: " + calc.getMax()); System.out.println(" Mean: " + calc.getMean()); System.out.println(" Standard Deviation: " + calc.getStandardDeviation()); } }

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. private double max = Double.NEGATIVE_INFINITY; // Largest item seen. private double min = Double.POSITIVE_INFINITY; // Smallest item seen. public void enter(double num) { // Add the number to the dataset. count++; sum += num; squareSum += num*num; if (num > max) max = num; if (num < min) min = num; } public int getCount() { return count; } public double getSum() { return sum; } public double getMean() { return sum / count; } public double getStandardDeviation() { double mean = getMean(); return Math.sqrt( squareSum/count - mean*mean ); } public double getMin() { return min; } public double getMax() { return max; } }

Help! The item = TextIO.getlnDouble(); isn;t working. Im suppose to enter numbers and than have the max, min, stdev, and mkean calculate & this line isn't working.

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!