Java with a for loop with in for loop -


i not sure why isn't working questionhave use 1 dimensional integer array count number of times each possible sum appears in 36000 rolls.

however problem keep getting 0.0 instead of 1200000 or 700000.

import java.util.arrays; import java.util.random;  public class stocksim {        public static void main(string args[]) {          double data[] = new double[10];            system.out.println(percentgen());          double percent;              (int = 0; < data.length; i++) {                 percent = percentgen();                 data[i] = data[i] + (data[i] * percent);             }         }          (int = 0; < data.length; i++) {             system.out.println(data[i]);         }      }      public static double percentgen() {         random rand = new random();           return randomnum;      } } 

it simple fix, forgot actual percentage dividing random percentage 1 hundred. substitute return randomnum return randomnum/100.

besides that, tested code , should working fine.

i hope helps!


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -