I put the same amount away every week and I want to know how
many weeks until I hit my goal. I already have some saved.
Tell me the week number and what I will have by then.
Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.
Notes
Nobody knows how many weeks this takes, including the program. That decides which loop you use, and it is the opposite of the other two challenges in this set.
Two of Activity 1.20's patterns are running at once here, and one of them is what gets reported at the end. The week number is not the same kind of thing as the money.
The week number has to survive the loop, so think about where it is declared.
Decide what happens if somebody already has more than their goal. Write the decision down first, then run it and check the program agrees with you. A loop that runs zero times is a real answer.
The last week usually overshoots the goal. That is correct behavior, and Activity 1.17's fuel tanks are why.
Sample Output
Sample Output
Currently saved: 120 [Enter]
Saving each week: 45 [Enter]
Goal: 300 [Enter]
Week 1: 165
Week 2: 210
Week 3: 255
Week 4: 300
You reach your goal in 4 weeks.
Test 120 / 45 / 300, then 400 / 45 / 300, then 0 / 45 / 300. The middle one is the case your written decision has to match.
Submit
Your requirements list and your program file, named cc-savings-goal.