Hi, I'm a computer dummy taking my first (and likely only) computer science course and I've begun to really struggle. I thought my current project was going well until I actually want to run the program and everything came out wrong. I was hoping that somebody would be able to point out where I made a mistake.
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
// Main Program
int main( )
{
// Constant Declarations
const double PI = 3.1415926535; // the radius/diameter of a circle
cout << fixed << setprecision(2);
// Variable Declarations
double p; // air density (entered by user; in kg/m^3)
double vel; // velocity of the rocket (entered; in m/s)
double cd; // drag coefficient of rocket (entered)
double diameter; // diameter of rocket (entered by user; in mm)
double dia2; // diameter of rocket (calculated; in m)
double area; // frontal area of rocket (calculated; in m^2)
double AeDrag; // aerodynamic drag acting on rocket (calculated;in n)
char ans; // y/n if user wants to run program again
do {cout << "enter air density at launch site (kg/m^3): ";
cin >> p;
cout << "enter velocity of the rocket (m/s): ";
cin >> vel;
cout << "enter coefficient of drag: ";
cin >> cd;
cout << "enter diameter of the rocket (mm): ";
cin >> diameter;
dia2=diameter/1000;
area= PI*(dia2/2)*(dia2/2);
AeDrag=drag(p, vel, cd, area);
cout << " The drag on the rocket is " << drag << " newtons. " << endl;
cout << "Would you like to run the program again (Y or N)?" << endl;
cin >> ans;
} while (ans =='Y' || ans == 'y');
Thanks a lot, that was a mistake that I should have caught. The final step is to add an exit function for if the velocity exceeds 300 m/s. How exactly do I implement the exit function?