- 2
Write program to find distance car has traveled after 10 seconds if it is initialy traveling at 60mph and decelerates at 12m/s^2
using the formula, distance=st-(1/2)dt^2 where s is the initial speed of the car d is the deceleration t is the elapsed time mph is miles per hour m/s^2is miles per square second #include <iostream> using namespace std; int main () { float velocity,time,deceleration,distance; cout <<"enter velocity"; cin>>velocity; cout <<"enter time"; cin>> time; cout<<"enter deceleration"; cin>>deceleration; distance=velocity*time-(1/2)deceleration*time*time cout <<"distance is"<<distance; }
4 odpowiedzi
+ 14
@Tehreem
in physics you have to convert mph into m/s which devide 60 with 3600 and multiply with 1.6
The result is float. you are using int.
try to solve the equation on paper. then you'll know what i mean. its negative decimal.
+ 12
@Tehreem
are you sure the initial velocity is 60 mph and the decelaration is 12 miles per second?
if it is true, the distance is 960 meter backward!
Because the deceleration is bigger than initial velocity.
i am not writing any code yet, just solve it in my head. just to make sure -960 meter is the answer you want.
+ 9
mph is miles per hour and mi/s is miles per second
+ 6
What exactly are mph and mi/s?