I'm sure this is probably a simple fix, but I have been searching for hours for a solution to no avail. I'm very new at c++ so any help here would be appreciated. My assignment is to create a program that will determine the duration of flight for a projectile and its height above the ground as it reaches a target. here is what I have so far:
// THIS PROGRAM IS INTENDED TO CALCULATE THE DURATION AND HEIGHT ABOVE GROUND OF A PROJECTILE IN FLIGHT
// AS IT REACHES ITS TARGET. CALCULATIONS ARE BASED ON: A GRAVITATIONAL CONSTANT OF G = 32.17, THE ANGLE OF THE
// PROJECTILE'S ELEVATION AT LAUNCH, THE PROJECTILE'S VELOCITY, THE DISTANCE TRAVELLED TO THE TARGED,
// AND WILL USE THE DOUBLE DATA TYPE FOR MORE PRECISION. TWO DATA SETS WILL BE SUBMITTED TO ENSURE ACCURACY.
double distance; //THE DISTANCE TO TARGET.
double velocity; //THE VELOCITY OF PROJECTILE.
double theta; //THE ANGLE OF ELEVATION AT LAUNCH.
double calHeight; //THE HEIGHT OF PROJECTILE ABOVE GROUND AT TARGET.
double calTime; //THE TIME OF FLIGHT.
//THIS FUNCTION DISPLAYS THE INFORMATION ABOUT WHAT THIS PROGRAM DOES
//AND TAKES INPUT FROM THE USER IN A SPECIFIC FORM.
instructions();
cout << "What is the angle of elevation in radians?" <<endl;
cin >> theta;
cout << "What is the velocity in ft/sec? " <<endl;
cin >> velocity;
cout << "What is the distance to target in feet?" <<endl;
cin >> distance;
cout << "The projectile was" << calHeight << "feet above ground and"
<< "was in the air for" << calTime << "seconds." <<endl;
return 0;
}
//THIS FUNCTION TELLS THE USER WHAT TO DO. THERE ARE NO INPUTS OR OUTPUTS.
void instrucitons()
{
cout << "To obtain the results for time and height you must input distance, velocity, and angle." <<endl;
}
//THIS FUNCTION TAKES DISTANCE, VELOCITY, AND THEN ANGLE AS INPUTS
//AND CALCULATES THE TIME THE PROJECTILE WAS AIRBORN.
double calTime(double, double, double);
{
double distance;
double velocity;
double theta;
double calTime;
calTime=distance/(velocity*cos(theta));
return calTime;
}
//THIS FUNCTION TAKES, VELOCITY, THE ANGLE, AND TIME (FOUND WITH THE PREVIOUS FUNCTION)
//AND CALCULATES THE HEIGHT OF THE PROJECTILE WHEN IT MEETS THE TARGET.
double calHeight(double, double, double);
{
double velocity;
double theta;
double calTime;
double calHeight;
is the code just out of order or do i have an incomplete function somewhere? here is what i have now:
// THIS PROGRAM IS INTENDED TO CALCULATE THE DURATION AND HEIGHT ABOVE GROUND OF A PROJECTILE IN FLIGHT
// AS IT REACHES ITS TARGET. CALCULATIONS ARE BASED ON: A GRAVITATIONAL CONSTANT OF G = 32.17, THE ANGLE OF THE
// PROJECTILE'S ELEVATION AT LAUNCH, THE PROJECTILE'S VELOCITY, THE DISTANCE TRAVELLED TO THE TARGET,
// AND WILL USE THE DOUBLE DATA TYPE FOR MORE PRECISION. TWO DATA SETS WILL BE SUBMITTED TO ENSURE ACCURACY.
double distance; //THE DISTANCE TO TARGET.
double velocity; //THE VELOCITY OF PROJECTILE.
double theta; //THE ANGLE OF ELEVATION AT LAUNCH.
double calHeight; //THE HEIGHT OF PROJECTILE ABOVE GROUND AT TARGET.
double calTime; //THE TIME OF FLIGHT.
//THIS FUNCTION DISPLAYS THE INFORMATION ABOUT WHAT THIS PROGRAM DOES
//AND TAKES INPUT FROM THE USER IN A SPECIFIC FORM.
instructions();
cout << "What is the angle of elevation in radians?" <<endl;
cin >> theta;
cout << "What is the velocity in ft/sec? " <<endl;
cin >> velocity;
cout << "What is the distance to target in feet?" <<endl;
cin >> distance;
cout << "The projectile was" << calHeight << "feet above ground and"
<< "was in the air for" << calTime << "seconds." <<endl;
return 0;
}
//THIS FUNCTION TELLS THE USER WHAT TO DO. THERE ARE NO INPUTS OR OUTPUTS.
void instrucitons()
{
cout << "To obtain the results for time and height you must input distance, velocity, and angle." <<endl;
}
//THIS FUNCTION TAKES DISTANCE, VELOCITY, AND THEN ANGLE AS INPUTS
//AND CALCULATES THE TIME THE PROJECTILE WAS AIRBORN.
double calTime(double distance, double velocity, double theta)
{
double calTime;
calTime=distance/(velocity*cos(theta));
return calTime;
}
//THIS FUNCTION TAKES, VELOCITY, THE ANGLE, AND TIME (FOUND WITH THE PREVIOUS FUNCTION)
//AND CALCULATES THE HEIGHT OF THE PROJECTILE WHEN IT MEETS THE TARGET.
double calHeight(double velocity, double theta, double calTime)
{
double calHeight;
calHeight=velocity*sin(theta)*calTime-((g*calTime*calTime)/2);
return calHeight;
}