Modify Assignment #10 so that it can take positive, zero, and negative floating point numbers and calculate the mean and standard deviation. Input ends when the user enters a string that can not be interpreted as a floating point number. Use exception handling to detect improper inputs.

This is my Assignment 10

To be done in Java OOP please

import java.util.Scanner;
public class DataSetTester {
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
DataSet test= new DataSet();
System.out.print(“Enter the values: “);
double values= 0;
while(values>=0){
values=scan.nextDouble();
if(values>=0){
test.addValue(values);
}
}
System.out.println(“Standard deviation is ” +test.getStandardDeviation());
System.out.println(“Your average is “+ test.getAverage());

}
}

public class DataSet {
private float sum;
private float sumOfSquares;
private int count;
public DataSet()
{
sum = (float) 0.0;
sumOfSquares = (float) 0.0;
count = 0;
}

public void addValue(double value)
{
sum += value;
sumOfSquares += Math.pow(value, 2);
count++;
}
//avg method created
public double getAverage()
{
return sum / (double)count;
}
//standard deviation method created
public float getStandardDeviation()
{
return (float) Math.sqrt( (((float)count * sumOfSquares) –
(sum * sum)) / ((float)count * ((float)count – 1)) );
}

}

"Get 15% discount on your first 3 orders with us"
Use the following coupon
"FIRST15"

Order Now