The position of a falling object can be calculated using the equation:

p(t) = -16t^2 + v0t + h0

Where:

t is the 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

As with previous weekly assignments, don't let the equations intimidate you. The first equation requires taking a square, performing two multiplications, and two additions. The second only requires a single multipllication and addition.

As an example, assume we drop a ball from an initial height of 500 ft. (H0 = 500.0) above the Earth. Since we dropped the ball and didn't throw it, its initial velocity is 0ft/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) + 500.0
P(5.0) = 100.0

V(5.0) = -32(5.0) + 0.0
V(5.0) = -160

Hence, after 5 seconds, the ball will be 100 feet above the ground traveling downwards at 160 ft/sec (downwards because of the negative sign).

Requirements:

Write a program that displays the position and height and velocity of an object for every second it drops, as long as it is above 1,000 feet. Also write a test plan for this program.

  • Tell The user what the program does before prompting for input.
  • Read from the user the initial height of the object
    • Only allow the user to enter a positive height, above 1,000 ft. If they do not, issue an error message and then re-prompt the user to enter the number again until the height entered is at greater than 1000.
  • Read from the user the initial velocity of the object.
    • The user may enter a positive (indicating the object was thrown upward), negative (indicating the object was thrown downward, or zero (indicating the object was just dropped) value for the initial velocity, but a negative velocity may not exceed a terminal velocity of -500 ft/sec.
    • If they enter a negative velocity that is smaller (i.e. more negative) than -500, issue an error message and then re-prompt the user to enter the number again, until the velocity entered is at least -500.
  • Implement the Position and Velocity calculations as calls to two different user-defined functions.
    • The first function will return the object's position at the current time
    • The second function will return the object's velocity at the current time
    • Pass any required information, including the current time in seconds, to the functions as parameters.
  • Air resistance affects the acceleration of falling objects, so they will eventually reach a maximum terminal velocity. The terminal velocity will vary, depending on the object's mass, but for this program we will not allow the velocity to ever exceed -500 feet/second.
    • If the fallig object has reached terminal velocity, you will no longer be able to use the P(t) function to calculate the position. Therefore, you should calculate the velocity first, and then check to see if terminal velocity was reached before calculating the position.
    • If terminal velocity has been reached, just subtract 500 ft from the previous position to get the new position, instead of calling the position function.
  • Display the time, the position, and the velocity of the object every second , formatted as shown in the output example below.
  • The program should cease displaying the height and velocity increments when the object reaches 1,000 feet above the ground and perform no more calculations.
  • As soon as the object is at or below 1,000 feet, display the final position, velocity, and seconds, formatted as shown in the output example below.
  • Ensure that you use constants where appropriate.

Sample Input

Program will calculate the position and velocity of a falling object

Enter the initial height in feet (above 1000): 500
Invalid answer. Must enter height over 1000. Enter the initial height in feet (above 1000): 6000

Enter the initial velocity in ft/sec: 50
Time Position Velocity
---- -------- --------
0 6000.00 50.00
1 6034.00 18.00
2 6036.00 -14.00
3 6006.00 -46.00
4 5944.00 -78.00
5 5850.00 -110.00
6 5724.00 -142.00
7 5566.00 -174.00
8 5376.00 -206.00
9 5154.00 -238.00
10 4900.00 -270.00
11 4614.00 -302.00
12 4296.00 -334.00
13 3946.00 -366.00
14 3564.00 -398.00
15 3150.00 -430.00
16 2704.00 -462.00
17 2226.00 -494.00
18 1726.00 -500.00
19 1226.00 -500.00
20 726.00 -500.00

From a height of 6000.00 ft
An initial velocity of 50.00 ft/sec
An object reaches 1000.00 ft
After 21 seconds
At a final position of 726.00 ft
With velocity of -500.00 ft/sec
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.