We will once again compare the days and count values as a way to determine if we should perform an action. This time, we want to know when to display the value in the newAmount variable:
If we started with one dog bone and doubled it every day for seven days, we would have ended up with 64 dog bones. Our Scratch program told us so. Our dog would love us.
When the count equaled the days, we told our sprite to say whatever amount was in the newAmount variable. Because the newAmount variable constantly changed throughout the program, the only calculated value we cared about was the last one. We knew we had the last calculated value when count < days no longer evaluated to true.
The first scenario to cause count not to be less than days was when count was equal to days, which was the logic we represented in our script.
We're finally ready to move on to the second piece of our problem. We now know how rapidly a single dollar can grow if we double it each day. For comparison, we're going to assume we have a lump sum of $15,000 that will accrue interest over a single time period, which we'll assume is 30 days.
We'll allow the user to set the interest rate. Instead of graphing this equation, we'll add a wise old sprite to do the math for us and report the total amount for comparison with the double graph.
3.143.4.181