Hello!
So i am a new programmer and i really need some help. I am trying to find the Population Standard Deviation of 7 numbers which the user inputs.
Please see below my - double dayOne, dayTwo, dayThree, dayFour, dayFive, daySix, daySeven, avgRain = 0, stanDeviation = 0, dayOneSq = 0, dayTwoSq, dayThreeSq, dayFourSq, dayFiveSq, daySixSq, daySevenSq, avgRainSq;
-
-
-
//Get rainfall information from users.
-
-
System.out.println("Enter rainfall measurement for Day 1 (in mm): ");
-
dayOne = reader.nextDouble();
-
-
System.out.println("Enter rainfall measurement for Day 2 (in mm): ");
-
dayTwo = reader.nextDouble();
-
-
Etc, Etc.
-
-
//find average
-
-
avgRain = (dayOne + dayTwo + dayThree + dayFour + dayFive + daySix + daySeven)/7;
-
-
// calculate population deviation
-
-
dayOneSq = (dayOne - avgRain);
-
Math.pow(2,dayOneSq);
-
-
dayTwoSq = (dayTwo - avgRain);
-
Math.pow(2,dayTwoSq);
-
-
etc..etc...
-
-
//find standard deviation
-
-
avgRainSq = (dayOneSq + dayTwoSq + dayThreeSq + dayFourSq + dayFiveSq
-
+ daySevenSq)/7;
-
-
stanDeviation = (Math.sqrt(avgRainSq));
-
-
-
System.out.printf (", Standard Deviation: %.4f\n\n",stanDeviation);
any hint would be fantastic!! Thanks!!!
2 2251
Please correct your post and use code tag to format your code.
You forgot to mention your problem. What did not work in a way you expected?
Tip:
You can reduce your code size by using arrays (or Lists) and for-loops: You should not use double day1, day2, day3 etc., but "double[] days = new double[7]" and access for example day 3 by "days[2]" ,or using a loop "for(int i=0; i < 7; i++){...}" with "day[i]"
Please use code tags when posting code.
You never assign the result of math.pow to anything. So you end up never having your squared differences. Also, your arguments need to be reversed, it's the first argument to the power of the second argument, not the reverse.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: T.Venkatesh |
last post by:
Hi friends,
I just got stuck up in JDBC,JSP.
My problem is iam unable to display the output of Standard deviation ,
variance sum, of a column in a JSP page. But it complies- but no
display of...
|
by: mat |
last post by:
Je l'ai cherché partout, je ne l'ai pas trouvé, alors je l'ai
écrite.
Si ça peut servir à d'autres ...
echo "Calcul d'un ecart type";
echo "<br>";
$datas =...
|
by: Scott |
last post by:
I know in some other languages there is a simple standard deviation function
(sdev(1,2,3,4,5,etc...)). But I'm unable to find a suitable alternative for
vb.net
I'm assuming it's there...
|
by: Quentin |
last post by:
How would I calculate standard deviation of a csv file? Any code
examples would be great!
Thank you!
|
by: Verbal Kint |
last post by:
DEAR ALL,
I just have a very short question. In the FAQ list question 13.20 the
following text is mentioned:
"These methods all generate numbers with mean 0 and standard deviation
1. (To adjust...
|
by: aboxylica |
last post by:
do v have a function to calculate variance, average and standard deviation in python??
|
by: kumarboston |
last post by:
Hi All,
I am trying to get an average value for my data, here is my data file
DATA FILE
EP1934.PDB 250 250 11.27
EP1934.PDB 251 251 12.7332
EP1934.PDB 252 252 6.38341
EP1934.PDB 253 253...
|
by: shibujohn82 |
last post by:
Hi,
My data set is followed like this... (as tab delimited input.csv)
First is column is gene name, second column is bn count, third colums is sh count.
ENSRNOG00000000417 42 102...
|
by: yawsam |
last post by:
How can i use aggregate function like count, sum and other to calculate standard deviation in SQL
|
by: Dave Smith |
last post by:
I’m hoping someone can help me with my newest rank issue.
I’m trying to get a rank my standard deviation so it will be a number below 1, the numbers I'm trying to rank are below.
Example:
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |