Ribbons
Every pumpkin of at least 20 kg gets a ribbon: a gold ribbon from 30 kg, a silver one from 25 kg and a bronze one from 20 kg. Below what the program prints so far, print every pumpkin, in the order of the lists, with its weight and its ribbon. Then count the ribbons of each color:
Heaviest: Grandpa Joe (31 kg)
Emma: 23 kg, bronze ribbon
Grandpa Joe: 31 kg, gold ribbon
Hugo: 18 kg, no ribbon
Anna: 27 kg, silver ribbon
Lily: 12 kg, no ribbon
Tom: 25 kg, silver ribbon
Ribbons: 1 gold, 2 silver, 1 bronzeWatch the boundaries: Tom's pumpkin weighs exactly 25 kg, so it gets a silver ribbon, and a pumpkin of exactly 30 kg would get a gold one.
A tip: one loop can do both jobs. In the lesson on loops, you counted several things in one loop, each in a counter of its own.
Instructions
Print every pumpkin with its weight and its ribbon.
Below, print how many ribbons of each color the pumpkins got.
Start programming for free
2/3