Question: 2 5 . 2 5 PRACTICE: Loops ( while ) * * : Output rocket height LAB ACTIVITY 2 5 . 2 5 . 1

25.25 PRACTICE: Loops (while)**: Output rocket height
LAB ACTIVITY
25.25.1: PRACTICE: Loops (while)**: Output rocket height
0/3
Suppose a launched toy rocket's height is computed as h = vi*t -5t2. vi is the initial velocity, and t is time in seconds since the launch (starting at 0). Write a program to read the initial velocity, then output the time and the rocket's height once per second. Stop when the height would be negative, meaning the rocket hit the ground (don't print the negative). Assume all values are integers. Ex: For input 20, the output is:
00
115
220
315
40
Hints:
Use a while loop.
t squared is easily calculated as t * t.
Use this expression for the while loop: (rocketHeight >=0).
Don't forget to increment time inside the while loop (else you'll get an infinite loop).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!