Advertisement
M_A_Tabarani

School Stuff 01

Oct 4th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. //To determine the velocity and distance travel of a car
  2.  
  3. #include <iostream>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main ()
  9. {
  10.     double ivelocity;   //initial velocity
  11.     double time;    //time
  12.     double acceleration;    //acceleration
  13.     double fvelocity;   //final velocity
  14.     double distance;    //distance,(m)
  15.  
  16.     cout<<"Initial velocity"<<endl<<"=>";
  17.     cin>>ivelocity;
  18.  
  19.     cout<<"Time taken (in seconds)"<<endl<<"=>";
  20.     cin>>time;
  21.  
  22.     cout<<"Acceleration"<<endl<<"=>";
  23.     cin>>acceleration;
  24.  
  25.         fvelocity=ivelocity+acceleration*time;
  26.         distance=ivelocity*time+(acceleration*pow(time,2)/2);
  27.  
  28.     cout<<"The car travel up to "<<distance<<"m, with velocity "<<fvelocity<<"m/s after "<<time<<"s"<<endl;
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement