Question: Task #5 Calculating the Standard Deviation We need to reconnect to the file so we can start reading from the top again. Create a FileReader
Task #5 Calculating the Standard Deviation
We need to reconnect to the file so we can start reading from the top again.
Create a FileReader object passing it the filename.
Create a BufferedReader object passing it the FileReader object.
Reinitialize the sum and count to 0.
Write a priming read to read the first line of the file.
Write a loop that continues until you are at the end of the file.
The body of the loop will:
convert the line into a double value and subtract the mean, store the result in difference
add the square of the difference to the accumulator
increment the counter
read a newline from the file.
When the program exits the loop close the input file.
The variance is calculated by dividing the accumulator (sum of the squares of the
difference) by the counter. Calculate the standard deviation by taking the square
root of the variance (Use the Math.sqrt method to take the square root).
Compile, debug, and run. You should get a mean of 77.444 and standard
deviation of 10.021.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
