Problem Summary and Equations
When an object is dropped or thrown from an initial position (height), formulas can be used to determine the object's position (height) and velocity at each second, as it drops.
The position of a falling object can be calculated using the equation:
P(t) = -16t2 + V0t + H0
where:
t is time in seconds
P(t) is the position of the object at after t seconds,
V0 is the initial vertical velocity of the object in feet/sec, and
H0 is the initial height of the object in feet.
Likewise, the velocity of the object at any given time can be calculated from the equation:
V(t) = -32t + V0
where:
t is time in seconds
V(t) is the velocity of the object at after t seconds, and
V0 is the initial vertical velocity of the object in feet/sec
Example: Assume we drop a ball from an initial height of 1000 ft. (H0 = 1000.0) above the Earth. Since we dropped the ball and didn't throw it, its initial velocity is 0 ft/sec (V0 = 0.0). At zero, the ball is not moving up or down.
Now we can ask:
How high above the ground and how fast is the ball traveling after 5 seconds (t = 5)?
To determine these values, simply plug in all the numbers to the previous two equations:
P(5.0) = -16(5.0)2 + (0.0)(5.0) + 1000.0 P(5.0) = 600.0
V(5.0) = -32(5.0) + 0.0 V(5.0) = -160
Hence, after 5 seconds, the ball will be 600 feet above the ground traveling downwards at 160 ft/sec (downwards because of the negative sign).
Program Requirements
Write a program that displays a countdown first, and then displays the position and velocity of an object for every second it drops, as long as it is above 500 feet
Required Control Structures
Within this program, you must use at least one of each of the following programming constructs:
· while loop
· do-while loop
· for loop
Required Classes and Methods
Two separate classes will be required for this program.
1. Define a class with properties and methods for a falling object.
The class will have the following private properties:
constant initial position
constant initial velocity
current time
current position
current velocity