There are many equivalent formulas to compute an answer to this question:
answer = (mark1 + mark2 + mark3) / 3 / 20 * 100
or
answer = (mark1 + mark2 + mark3) / 3 * 5
or
answer = (mark1 * 5 + mark2 * 5 + mark3 * 5) / 3
So, here is an algorithm that corresponds with the second formula:
1 Declare mark1, mark2, mark3, average1, ratio, average2
2 Get 3 input values: mark1, mark2, mark3
3 Calculate the average mark out of 20, average1
4 Set ratio (the ratio between the averages) to 5 (= 100 / 20)
5 Calculate the average mark out of 100, by multiplying average1 by ratio
The trace table may look similar to this one:
mark1 mark2 mark3 average1 ratio average2
2 15 20 10
3 15 20 10 15
4 15 20 10 15 5
5 15 20 10 15 5 75
Comments
Leave a comment