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
any hint would be fantastic!! Thanks!!!
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
Code:
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);
Comment