public
anonymous / gist:4950899
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#include <iostream>
#include <cmath>
using namespace std;
 
int main()
{
double int_V, theta_deg, incrValT, endValT;
double theta_rad;
double time = 0.0;
double x, y = 0, maxHeight;
const double A = 32.2; //constant, acceleration due to gravity = 32.2 fps
const double PI = 3.14159;
cout << "Enter Initial Velocity (feet/second):"<<endl;
cin >> int_V;
 
cout << "Enter Launch Angle (degrees):" << endl; //user inputs
cin >> theta_deg;
 
cout << "Enter Increment Value for Time (seconds):" <<endl;
cin >> incrValT;
 
cout << "Enter End Value for Time (seconds) :" << endl;
cin >> endValT;
 
theta_rad = theta_deg *(PI/180.0); //convert degrees to radians
 
 
cout <<endl;
cout << " Time (s) X-Position (ft) Y-Position (ft) " <<endl;
 
 
for( time = 0; time <= endValT ; time = time + incrValT)
{
x = (int_V) * (cos(theta_rad) * time);
y = (int_V) * (sin(theta_rad) * time) - (0.5) * (A) * (time * time);
cout << time << " " << x << " " << y << endl;
if (time==0) maxHeight=y; //initialize maxHeight
if (y > maxHeight) maxHeight = y;
}
cout << " Max Height = " << maxHeight << "feet" <<endl;
 
system("pause");
return 0;
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.