/*************************************************************
  File: projectile.cpp
  Name: CDR B. A. Osborn
  Description: Pass by reference example modifying multiple
               parameters.
************************************************************/
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
 
bool launch_results(int, double, double&, double&, double&);
 
int main() 
{
 
        double i_vel, height, time, range;
        int alpha;
 
        cout<< "Enter initial velocity and launch angle (in whole degrees) : " ;
        cin >> i_vel >> alpha;
 
        if (launch_results(alpha, i_vel, range, height, time))
               cout << "Launch greater than 2000" << endl;
        else
               cout << "Launch less than than 2000" << endl;
 
        cout << "Vel" << '\t' << "Angle" << '\t' << "Height" << '\t'
                << "Time" << '\t' << "Range" << endl;
 
        cout << i_vel << '\t' << alpha << '\t' << height << '\t'
                << time << '\t' << range << endl;
 
        return 0;
}
 
bool launch_results(int deg, double vel, double& rng, double& ht, double& time)
{
        const double GRAVITY = 9.8;
        const double PI = 3.1415926;
        double radians;
        
        radians = (PI * deg)/180.0;
        ht = pow (vel * sin(radians), 2.0)/(2 * GRAVITY);
        time = (2 * vel * sin(radians))/GRAVITY;
        rng = (pow(vel, 2.0)/GRAVITY) * sin(2*radians);
 
        if (rng > 2000)
               return true;
        else
               return false;
        
}
 
 
 

syntax highlighted by Code2HTML, v. 0.9.1