Answer to Question #94095 in Algorithms for Angel Ann Ramos

Question #94095
Write an algorithm to calculate the average mark out of 100, given three assignment marks, each of which is marked out of 20.
Trace the algorithm using 15, 20 and 10 as the three assignment marks.
1
Expert's answer
2019-09-09T05:03:09-0400

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


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS