java - How to write the array procedure function here? -
double arr[] = new double[j]; (int i=0; i<j; i++) { arr[i] = double.parsedouble(joptionpane.showinputdialog(null, "please insert value : ")); } double result = calc.average(arr[i]); // how can return here? how can call function of public double average(int[] arr) in main function, if there array?
logically should done other way around. have function calculate sum of array call function in average method divide answer returned sum number of elements in array.
since above method has input, full array should sent method called average (not 1 array element) average method uses method called sum passing array there , receiving sum. working out average mentioned above
Comments
Post a Comment