Question: I need help making a stat calc in java ( main ) . Use the partial solution as a format and try to keep everything
I need help making a stat calc in java main Use the partial solution as a format and try to keep everything beginner level.
A common programming task is computing statistics of a set of numbers. A statistic is a number that summarizes some property of a set of data. A common statistic include the mean also known as the average StatCalc 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. Ifcalcis an object of typeStatCalc then the following methods are defined:
calc.enteritem;whereitemis a number, adds the item to the dataset.
calc.getCountis a function that returns the number of items that have been added to the dataset.
calc.getSumis a function that returns the sum of all the items that have been added to the dataset.
calc.getMeanis a function that returns the average of all the items.
Typically, all the data are added one after the other calling theentermethod 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. The methodsgetMean should only be called if the number of items is greater than zero.
Add instance methodsgetMaxandgetMin ThegetMaxmethod should return the largest of all the items that have been added to the dataset, andgetMinshould return the smallest. 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 Testjava by using it in a program to compute statistics for a set of nonzero numbers entered by the user. Start by creating an object of typeStatCalc:
StatCalc calc; Object to be used to process the data. calc new StatCalc;
Read numbers from the user and add them to the dataset. Use as a sentinel value that is stop reading numbers when the user enters After all the user's nonzero numbers have been entered, print out each of the six statistics that are available fromcalc
Partial Solution:
public class TestStats
public static void mainString args
int userNum;
StatsCalc test new StatsCalc;
do
userNum testenterItem;
if userNum
testdisplayStats;
while userNum ;
import Scanner
public class StatsCalc
notice there is no main method here
public class Calc
instance variables go here
do not include Standard Deviation
remove this and any associated methods
from your class
if Scanner is imported to this class,
then a new object should be here too
defult constructor
public StatsCalc
public StatsCalcint uN
If the user input is coming from the other class,
then you need a parameter constructor too
public double enterItem
This is a good spot to give the user instructions
this could be void if Scanner is instantiated in TestStats
userNumber ionextDouble;
return userNumber;
public void getMax
if xxxxxxxxxxxx yyyyyyyyy
yyyyyyyyyy xxxxxxxxxx;
public void getMin
public void displayStats
getMax;
getMin;
output to the user goes here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
