Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago