Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
A stamp card gives a free coffee after every 10 paid coffees. Start at 0 stamps.
Simulate buying coffees one at a time: each purchase adds 1 stamp. When stamps reach 10, the customer gets a free coffee-reset stamps to 0 and count 1 free drink earned.
Keep simulating paid purchases until 2 free rewards have been redeemed (each time stamps hit 10, award a free drink and reset stamps to 0). After each paid coffee, print the current stamp count.
Skills: while, modulo or subtraction, reset pattern.