Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Loop termination by counter method Write a pseudocode algorithm that calculates

ID: 3869694 • Letter: L

Question

Loop termination by counter method Write a pseudocode algorithm that calculates and prints the average number of goals scored per team for a series of soccer match scores. Your algorithm should initially ask the user for the number of soccer match scores that are to be entered. Use a counter loop to ensure that the loop repeats that number of times. Inside the loop, your algorithm should ask the user to enter two scores, one for each team. To read in the two scores, simply use two separate input statements in the normal manner. The algorithm should generate a display of prompts, inputs, and final output that looks like this: Sample session: How many soccer match scores would you like to enter?3 Enter score (using a space to separate the goals): 1 0 Enter score (using a space to separate the goals): 1 2 Enter score (using a space to separate the goals): 4 1 Average number of goals scored per team -1.5 Provide a graceful response if the number of scores equals zero: How many soccer match scores would you like to enter? 0 Average number of goals scored per team cannot be calculated.

Explanation / Answer

Algorithm CalculateAverage()

start

print "How many soccer matches would you like to enter: "
n = input()
team1 = 0
team2 = 0

for i=1 to n

loop begin

   print "Enter score (using a space top seperate the goals): "
    t1 = input()
    t2 = input()
   team1 = team1 + t1
   team2 = team1 + t2

loop end

sum = (team1 + team1)/n
average = sum/2

return average

end

================================
Thanks, let me know if there is any doubts