Unit 2 Task 22: Savings goal

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Unit 2 Task 22 - Savings goal

← Unit 2 tasks · Solution


You start with $0. Ask for a goal amount (float) and then repeatedly ask how much you save this week (float). Add each week’s savings to your balance.

Stop when your balance is greater than or equal to the goal. Then print how many weeks it took and the final balance.

Skills: while with a condition on a running total, week counter.