I am working on a program that computes the duration of a projectiles's flight and its height above ground when it reacdhes the target. I can get it to compile and run but the math is wrong. Can anyone please help?
#include <stdio.h> /*printf, scanf definitions*/
#include <math.h> /*cos definition*/
#define G 32.17 /*gravitational constant*/
int
main(void)
{
double Theta; /*input-angle(radians)of elevation*/
double Distance; /*input-distance (ft) to target */
double Velocity; /*input-projectile velocity (ft/sec)*/
double Time; /* output-time(sec) of flight*/
double Height; /*output-height at impact*/
/*opening explanation to user*/
printf("This program computes the duration of a projectile's flight and its height above the ground when it reaches the target. To use this program, enter the angle, the distance, and the velocity after each of the prompt.");
printf("Enter the angle of elevation in radians>");
scanf( "%f", &Theta );
printf("Enter the distance to target in feet>");
scanf( "%f", &Distance );
printf( "Enter the projectile velocity in ft/sec>");
scanf( "%f", &Velocity );
Time = Distance / (Velocity * cos(Theta)) ;
Height = Velocity * sin(Theta) * Time -G*Time*Time/2.0;
printf("The time of flight is %.3f seconds.\n", Time);
printf("The height at impact is %.3f feets.\n", Height);
system ("pause");
return (0);