java - Working with computing changes with Arrays -
i trying compute changes via java programming --> parallel arrays. reason keep getting "0s" output. rest of program runs fine.
here part of program "computing" occurs.
public int computepopulationchange(int population2010[], int population2000[]) { populationchange[count] = population2000[count] - population2010[count]; return populationchange[count]; }//end computepopulationchange public double computepercentchange(int population2010[], int population2000[]) { percentchange[count] = ((population2000[count] - population2010[count])/population2000[count]) * 100; return percentchange[count]; }//end computepercentchange
are there specific steps take when trying compute numbers data file? not sure missing in whole program.
you're not iterating on arrays. consequently, you're not filling result array.
if result should parallel array, consider this:
public int[] computepopulationchange(int population2010[], int population2000[]) { int count = population2010.length; int[] result = new int[ count ]; ( int = 0; < count; ++i ) { result[i] = population2010[i] - population2000[i]; } return result; }//end computepopulationchange
Comments
Post a Comment