View Full Version : Calculate Average when some numbers are blank

01-26-2010, 07:57 PM
Greetings All,

I know some of you experts will be able to help me.

I have a form in Adobe that lists ratings for various tasks, ranking from 1-3. I need to put in a box that tabulates the average for the section. That is itself has thus far been pretty simple.

My problem is that the number of tasks is variable. There may be 8 tasks on one form, but only 2 on another. Is there a way to calculate the average of only the number of ratings that are actually 1-3, leaving out the ones that have no ratings because there is no task? In other words, I can't just say to calculate the average of the 8 items, because there may be only two tasks that have been rated.

I hope this makes sense and that someone can help! Thanks in advance for any assistance you can provide.

02-16-2010, 12:49 AM
I believe what you are looking for is an ArrayList.
Take a look at this and see if it is what you need.

It has a variable size and is probably not as fast if you are working with a very large amount of data...but i think it will do
fine in your case.

If it is too slow, which could be the case, then just use a normal array and parse through it to remove unneeded information. Afterwords re-size the array (unfortunately java, as far as I know, does not have this built in so you will have to create this method yourself).