## Rocketry Program Problems

I've been making a program for my Civil Air Patrol rocketry teacher that will calculate the total altitude of a rocket in both a dragfree and normal enviroment. The drag free code works fine but the normal code (DMotor and DRocket) don't give me good output. Can anyone identify a problem? I'm using VC6 on Windows 98.

Code:
```#include <math.h>
#include "conversion.h"
#define g 9.81
#define p 2.696
#define rho 2.696
#define GRAV 32.2

double sqr(double inp)
{
return inp*inp;
}

struct OutputData
{
double Sb, Sc, St, VMax, VAve;
};

struct DOutputData
{
double yc, y1, yt;
};

class DFreeMotor
{
public:
double Weight, TImpulse, TImpP, AveT, MaxWeight;
double BurnW, TDur, VMax, VAve, Sb, Sc, St;
DFreeMotor()
{
Weight = 3.12;
TImpulse = 2.5;
AveT = 8;
TDur = 0.32;
MaxWeight = 113.2;
TImpP = 100;
}
OutputData OutD;
OutputData Calc(double LiftW);
};

OutputData DFreeMotor::Calc(double LiftW)
{
TImpulse *= (TImpP / 100);
TImpulse = NSecLBSec(TImpulse);
BurnW = LiftW - Weight;
BurnW = GramLB(BurnW);
TDur = TImpulse / AveT;
VMax = TImpulse*GRAV/BurnW;
VAve = VMax/2;
Sb = VAve * TDur;
Sc = sqr(VMax)/(2*GRAV);
St = Sb + Sc;
OutD.Sb = Sb;
OutD.Sc = Sc;
OutD.St = St;
OutD.VMax = VMax;
OutD.VAve = VAve;
return OutD;
}

class DFreeRocket
{
public:
DFreeMotor Engine;
double Weight;
DFreeRocket()
{
Weight = 32;
}
OutputData OutD;
OutputData Calc();
};

OutputData DFreeRocket::Calc()
{
OutD = Engine.Calc(Weight);
return OutD;
}

class DMotor
{
public:
/*
Terms:
m : Rocket Mass (KG)
A : Rocket Cross-Sectional Area in m^2
cd: Drag Coefficient = 0.75 for average rocket
t : Burn Time, Thrust Duration
T : Average Thrust
I : Motor Impulse
v : Burnout Velocity
y1: Burnout Altitude
yc: Coasting Distance
ta: Coasting time => Delay Time for Motor
mr: Empty Rocket Mass
mp: Propellant Weight
*/
double m, A, Cd, t, T ,I, v, y1, yc, ta, maxw, mr, me, mp;
double k, q, x, qa, qb;
DOutputData OutD;
DOutputData Calc(double LiftW);
DMotor()
{
mp = 3.12;
I = 2.5;
T = 8;
maxw = 113.2;
I = 100;
Cd = 0.75;
}
};

DOutputData DMotor::Calc(double LiftW)
{
me = LiftW;
mr = 2.0;
m = mr + me - (mp/2);
k = 0.5 * rho * Cd * A;
q = sqrt((T-(m * g))/k);
x = ((2 * k * q)/m);
t = I / T;
v = q * (1 - exp(-x * t)) / (1 + exp(-x * t));
y1 = (-m/(2 * k)) * log(((m * g) + (k * sqr(v))/(T - (m * g))));
m = mr + me - mp;
yc = (m/(2 * k)) * log(((m * g) + (k * sqr(v)))/(m * g));
qa = sqrt((m * g) / k);
qb = sqrt((g * k) / m);
ta = (tan(v / qa)) / (qb);
OutD.yc = yc;
OutD.y1 = y1;
OutD.yt = yc + y1;
return OutD;
}

class DRocket
{
public:
DMotor Engine;
double Weight;
DRocket()
{
Weight = 32;
}
DOutputData OutD;
DOutputData Calc();
};

DOutputData DRocket::Calc()
{
OutD = Engine.Calc(Weight);
return OutD;
}```
THANKS