Suppose I have a set of weighted grades for a subject in high school. Like this: 8.4 (weight: 3), 7.2 (weight: 1), 3.4 (weight: 3).
When I loop over that set like this:
totalCount: Double
totalWeight: Integer
for grade in grades {
totalCount += grade * weight
totalWeight += weight
}
average = totalCount / totalWeight
That gives me the current average. Which is fine, but I want to calculate what grade I should score for a given weight to precisely get an average of 5.50.
That means I only want to calculate what grade I should score, as the user chooses the weight.
That means I should use this equalization: 5.50 = ((grade1 * weight1) + (grade2 * weight2) .... + (gradeToBeCalculated * givenWeight)).
I'm not entirely sure how to do this in programming code, has somebody got examples for me?
The thing is, I want to add a grade to the equation as mentioned above, but I'm not sure how I should calculate what that grade should be with the weight given by the user.
– Johann Behrens Jan 25 '16 at 09:315,7with weight3already, when I use your formula for weight1I should score a4,9. When I use that in the basic formula to calculate my new average, it says5,5.Thank you so much, GoodDeeds!
– Johann Behrens Jan 25 '16 at 10:03Thanks so much :D
– Johann Behrens Jan 25 '16 at 10:11