I am having a little trouble here and hope someone might know the answer. I have 2 arrays, one of them double and one of them integer. Now I know at the get go that I could set everything up using doubles and it would all work fine. However, that is not what I want to do (although it looks like I am not going to get to do what I want).
Below is an algorithm for defining the average of a set of scores. averageArray is double, averageScore is double, but totalScore and numGrades are both integers. Now I know that when an integer is divided by an integer the result is concatenated. It was my believe that by simply expressing them as double values that would remediate the issue. Thus if my average score should be 95.5 it would be expressed that way. However, even doing what I did below still results in 95.0 instead of 95.5. Is there some way that I can make this work the way I would like?
for (int i = 0; i < classSize; i++)
totalScore = 0;
for (int j = 0; j < numGrades - 1; j++)
totalScore += scoreArray[j];
averageScore = double(totalScore) / double(numGrades - 1);
averageArray = averageScore;