# Counting in Array List/ Standard deviation

Ron Ingram

Ranch Hand

Posts: 73

posted 4 years ago

Hello all,

I'm working on an assignment that I can't seem to get my arms around. Basically, I have to supply values and count the number of entries, provide a sum for each number added,an average and standard deviation. Right now, I'm trying to correctly add each entry into the list and get the count, sum and average. For some reason, it doubles each entry within the LIst, so that if I provide one entry of '5', it adds it twice when getting the sum.

Please review what I have and provide any/all the help you can. Thank you.

This is the tester class:

Here is the dataset class

I'm working on an assignment that I can't seem to get my arms around. Basically, I have to supply values and count the number of entries, provide a sum for each number added,an average and standard deviation. Right now, I'm trying to correctly add each entry into the list and get the count, sum and average. For some reason, it doubles each entry within the LIst, so that if I provide one entry of '5', it adds it twice when getting the sum.

Please review what I have and provide any/all the help you can. Thank you.

This is the tester class:

Here is the dataset class

posted 4 years ago

Yep.

On row 34 you add the new number to the sum.

On row 43 you start to loop and add the new number again.

Why not make a method that sums it up when asked to do it? One method should do one thing. Add-method should add the number to the list, sum-method return the sum. avg-method the average.

On row 34 you add the new number to the sum.

On row 43 you start to loop and add the new number again.

Why not make a method that sums it up when asked to do it? One method should do one thing. Add-method should add the number to the list, sum-method return the sum. avg-method the average.

Ron Ingram

Ranch Hand

Posts: 73

Ron Ingram

Ranch Hand

Posts: 73