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

double time2 (double v, double a)
{
double t;
v=v*2;
t = v*sin (a)/9.8;// 9.8 equals gravity
return t;
}
double distance2 (double v, double a)
{
double d;
a=a*2;
d = pow(v,2)*sin (a)/9.8;
return d;
}
double height2 (double v, double a)
{
double h;
v=pow(v,2);
h = v*sin(a)/9.8;
return h;
}
int main()
{
double v=0, a=0, t=0, h=0, d=0;
const float PI = 3.145; // const of pi
cout<<"This program will calculate the distance, time, and height\n";
cout<<"of a projectile fired.\n";
cout<<"Please enter the angle and speed of the projectile to\n";
cout<<"calculate the values of distance, time, and height.\n";
cout<<"Angle: ";
cin>>a;
cout<<"Speed: ";
cin>>v;
a=a*(PI/180); //degrees into radian
t = time2(v,a);
cout<<"Time that the projectile stayed in the air is: " << t << endl;
d = distance2(v,a);
cout<<"the distance the projectile traveled is: " << d << endl;
h = height2(v,a);
cout<<"the height that the projectile reached is: " << h << endl;
system("pause");
}
 