In class were learning about classes and structures, Im working on a program that is supposed to have to member functions in the class, one doing calculations and one to return certain values, it seems Im running into trouble calling the functions maybe? IM not a 100% sure because c++ cant specify the error. I hope you can help me, thank you in advance.
#include <iostream>
#include <cstdlib>
using namespace std;
void rocket(double massR,double massE, double massP,double avgTh,double bd);
double rocketreturn(double& MV,double& MA);
class Rocket
{
private:
double massR;
double massE;
double massP;
double avgTh; // average thrust
double bd; //burn duration
public:
void rocket(double massR,double massE, double massP,double avgTh,double bd)
{
massR=massR/1000;
massE=massE/1000;
massP=massP/1000;
double LM=massR+massE;
double MCP=massR+massE-massP;
double AM=(LM+MCP)/2;
double acc=(avgTh/AM)-9.8;
double MV= acc * bd;
double Alt=.5*acc*.5*.5;
double t=MV/9.8;
double MA=Alt+MV*t+.5*-9.8*t*t;
}
double rocketreturn(double& MV, double& MA)
{
cout<< MV;
cout<< MA;
}
};
int main( )
{
double massR; // mass of the rocket
double massE; // mass of the engine
double massP; // mass of the propellant
double avgTh; // average thrust
double bd; // burn duration
double MV; // max velocity
double MA; // max altitude
char ans;
system("CLS");
cout << "Take Home # by - "
<< "Rocket Object\n\n";
do
{
cout <<"Enter the mass of the rocket: "<<endl;
cin >> massR;
cout <<"Enter the mass of the engine: "<<endl;
cin >> massE;
cout <<"Enter the mass of the propellant: "<<endl;
cin >> massP;
cout <<"Enter the average thrust of the engine: "<<endl;
cin >> avgTh;
cout <<"Enter the burn duration of the engine: "<<endl;
cin >> bd;
rocketreturn(MV,MA);
cout <<"the rockets maximum velocity is " << MV<<endl;
cout <<"the rockets maximum altitude is "<<MA<<endl;
cout <<"Would you like to run the program again (Y or N)?"<<endl;
cin>>ans;
}
while(ans=='y'||ans=='Y');
}