Skip to content

anonymous /gist:4950899
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.