/* Chris Davis
File name: daviscd2b.c
COMP 1200 - Fall 2006
Assignment 2
Program: Projectile's flight time and height
----------------------------------------------------------------------
This program will determine a projectile's flight duration and maximum
height given inputs of angle of elevation in degrees, velocity of the
projectile in feet per second, and distance to the target.
----------------------------------------------------------------------
*/
#include <stdio.h>
#include <math.h>
int main()
{
float degangle;
float velocity;
float distance;
float time;
float height;
float radangle;
float G;
float PI;
G = 32.17;
PI = 3.14159;
{
printf("Enter the angle at which the projectile was launched in degrees.\n");
scanf("%d", & degangle);
if (degangle == 90)
printf("Error: Denominator is equal to zero. Please reenter data.\n");
}
{
printf("Enter the distance the target is away in feet.\n");
scanf("%d", & distance);
}
{
printf("Enter the velocity at which the projectile was launched in feet per second.\n");
scanf("%d", & velocity);
if (velocity == 0)
{
printf("Error: Denominator is equal to zero. Please reenter data.\n");
return 0;
}
}
time = distance / (velocity * cos(degangle*PI/180));
height = velocity * time * sin(degangle*PI/180) - G/2 * pow(time,2);
radangle = degangle;
printf("The time the projectile is in flight is %5.2f\n", time);
printf("The maximum height in feet is %5.2f\n", height);
printf("The Angle of Elevation in Radians is %5.2f\n", radangle);
}