Hi, I need to write a program that calculates the distance of a golf ball dropped from an airplane in t seconds; The program displays the distance fallen in each second interval for 10 seconds and the total distance the golf ball falls at the end of each interval.
This is my code
I dont' know how to make the time to start form zero, i tried making time = -1, but i does not work because it will give me a negative distance. I would appreciate any help; Thanks
I wonder if the guys finished the physics library yet... Man I wish I didn't bail on that project.
Your "time" variable is starting at 0, I know this because you set it to 0. You are incrementing it before you display it though. You should move your 'cout' statement higher in the loop.
You're kind of close but there is confusion.
Let totDistance = how far ball has fallen since release from plane.
Let distance = how far ball has fallen in the last second. Initialize to 0 (you don't presently).
Your formula gives totDistance so try this in your loop:
1 2
totDistance = 0.5*Gravity*time*time;// I wouldn't use pow() just to square - but you can.
distance = totDistance - distance;// subtracting last distance from new distance = difference