Here are some hints for one possible way to write the code:
- Create variables Heads, Tails, Total to keep track of the number of heads, tails and total tosses, and initialize these variables.
- Create a custom
TossCoin
block that simulates a coin being tossed (by rapidly switching between the "Heads" and "Tails" costumes a few times before randomly settling on a choice), and updates the variables accordingly.
- Ask the user how many times they wish to toss the coin, and repeat the simulation that many times.
- Play the "Pop" sound that signals the end of a flip.
- Add a brief pause between each toss so the user can see what's happening. (But make sure to eliminate this pause when simulating 100's of coin tosses.)