I think what you probably need to do is sum all of the students' scores and then divide by the number of students. The average should be either a float or a double. Since all the scores are presumably int's and the number of students is an int. In Java an int/int calculation equals an int, so you will need to perform a cast.
Yes, average[] could be made a double unless you really need it to be the int value. A cast on the final calc isn't needed though because "sum" is already a double and the double/int result will still be a double.
I need all the averages I collected in the array to be added together and divided by the number of students (c) to equal the sum. I just don't know how to write it out.
The problem isn't the logic it's just how to do it...whenever I type in something like sum += average[i] / c it says sum may not be initialized...I don't know how to put it.
Last edited by cat8882; Nov 15th, 2007 at 4:57 pm.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.