10.10. Chapter ExercisesΒΆ

The following program calculates the height of an object as it falls from 1000 feet. The program should use a loop to print out the current height, then update the time by one second and calculate a new height. It should stop looping once the object reaches the ground (height 0) and then print out the final number of seconds.

Put the blocks in the right order and indentation. As usual, you will not use all the blocks.

To count how many digits there are in a number, you can do the following:

while the number is greater than 0
    set the number to the number divided by 10 (ignore any remainder)
    add one to the number of digits

Below is a function digitsIn that is supposed to calculate the number of digits in A given number. You need to write the logic to calculate that.

Hint: when you divide number by 10, make sure to use // to do whole number division.

Remember the debugging tricks you used - use codelens or print out values to make sure your work is correct.

Below is the start of a program to calculate how long it will take to have at least $50,000 if you invest $300 per month at 0.5% interest per month (approximately 6% per year).

You should add code to continue doing the following until money reaches 50000:

  • Increase the existing money by 0.5% (multiply it by 1.005). (This is interest earned on all money already invested.)

  • Add the monthly investment amount to money. (This is another month of investment.)

  • Increase the months count by 1

Remember the debugging tricks you used - use codelens or print out values to make sure your work is correct.

You have attempted of activities on this page