Write an algorithm, in the form of a Pseudo Code?

  • inputs the Weight of 1000 items
  • outputs the Weight of the heaviest and the lightest item
  • outputs the average (mean) weight of all the items input.

Solution

heaviest <– 0: lightest <– 100: total <– 0
for count <– 1 to 1000
     input weight
     if weight > heaviest then heaviest <– weight
       else if weight < lightest then lightest <– weight
     total <– total + weight
 next count
 average <– total/1000
output average,heaviest,lightest