File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with arrays

 
Shawn Houston
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i have a program that takes 4 orchards over a 5 year span. I need to get the average of each orchard. Which I have..now i need to get the Total of the 4 orchards for each of the 5 years..then the average for each year which I'm having a real trouble doing.



I just can't seem to get the totals for each seperate year and the averages.
What i thinking is I have to:
for(i = 0; i < 4; i++) {
for(j = 0; j < 5; j++)
year_total[i] += peach[0][0] +peach[0][1] + peach[0][2] + peach[0][3];
year_avg[i] = (float)(year_total[i] / 4.0);

For each consecutive year..but when i do that it adds both years then averages them. Not sure where I'm going wrong here nor how to put all the years into 1 for statement if its even possible.
 
Jimmy Die
Ranch Hand
Posts: 97
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Something a little different but a little the same:

[ November 29, 2004: Message edited by: Jimmy Die ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic