- Where Developers Learn, Share, & Build Careers
I am trying to use an array originally, which is data read from a file, and then Calculates the meaning and standard deviation from the data by using that array.
I can not get the right number right now. Stable public double [] [] calcStats (string [] [] x) throws IOException {double [] [] array = new double [7] [2]; Double total = 0, std_dev = 0, zodiac = 0; Int row2 = 0; {Array [line2] [0] = (total) for (line line = 1; row; lt; x.length; line ++); Array [row 2] [1] = amount of mathematics (amount); Zodiac = 0; Total = 0; If (line & gt; = 2) {row2 ++; } (Int col = 1; col & lt; x [row] height; cola ++) {total + = integer ParseInt (x [row] [col]); If (colley == 4) {total = (total / 4); }} For (int col = 1; col & lt; x [row] .length; col ++) {std_dev = (integer. ParseInt (x [row] [col]) - (total); Std_dev = Math.pow (std_dev, 2); Zodiac = + std_dev; Std_dev = 0; If (colley == 4) {zodiac = (zodiac / 27); }}} Array [row 2] [0] = (total); Return array; }
Array starts with 0 in Java. You are starting your end on 1. This means that you are not remembering the first element of each array.
According to Marco Topolony's suggestion, let me tell you that I have zodiac = + std_dev;
zodiac + = std_dev in its original code Now that I think about it, it was an invalid edit because the original code was an additional problem (except for the limit of the loop) I rolled back the edit to Marco's version.
Comments
Post a Comment