#include "magic.h"
#include <conio.h>
#include <iostream>
using namespace std;
int main()

{
float throttle;
float frate_;
const float time = 10000;
float vvel_ = 5;
cout << "Hey, this is starfleet, your orders are to safely land this ship"
<< " with a " << endl << "velocity greater than " << vvel_
<< "good luck captain "<< endl << endl;

lunar_lander s(1000.0, 0.0, 10.0,900.0,0.0,5000.0,900.0);
while(s.getalt() > 0)
{

cout <<"Altitude is " << s.getalt() << endl;
cout <<"Fuelleft " << s.getmassl() << endl;
cout <<"Thrust " << s.frate(throttle/10) << endl;
cout <<"Velocity is " <<s.vvel() << endl;
cin >> throttle;
}
getch();
}
// FILE MAGICS.H
 
#ifndef LUNAR_LANDER
#define LUNAR_LANDER
using namespace std;
class lunar_lander
{
public:

lunar_lander(float, float, float, float, float, float, float);

void setLunar(float alt, float vvel, float tankf, float frate, float massl, float thrust, float fuelconsum);

// ALTITUDE AND ACCESSOR

const float getalt();

// VERTICAL SPEED AND ACCESSOR

float vvel();

const float getvvel();
// FUEL IN TANK AND ACCESSOR

const float gettankf();

// FUEL FLOW RATE AND ACCESSOR
float frate(float);
const float getfrate();

// LANDER MASS AND ACCESSOR
const float getmassl();
// LANDER THRUST AND ACCESSOR
const float getthrust();
// MAX FUEL CONSUMPTION RATE AND ACCESSOR
const float getfuelconsum();
// WHEN LUNAR LANDS
int landed();
// TIME
float time(float);
void time();
private:
float alt_;
int count;
float vvel_;
float tankf_;
float frate_;
float fuelconsum_;
float thrust_;
float massl_;
float time_;
};
#endif
#include "magic.h"
#include <iostream>
using namespace std;
lunar_lander::lunar_lander(float a, float vs, float fl, float t, float fr, float thr, float ml)
{
alt_ = a;
vvel_ = vs;
fuelconsum_ = fl;
tankf_ = t ;
frate_ = fr;
thrust_ = thr;
massl_ = ml;
}
void lunar_lander::setLunar(float alt, float vvel, float tankf, float frate, float massl, float thrust, float fuelconsum)
{
if(alt >0 && alt <1000)
{
alt = alt_;
}
else
{
cerr << "What" << endl;
}
if( vvel > 0 && vvel <5400)
{
vvel = vvel_;
}
else
{
cerr << "VELOCITY!"<< endl;
}
if(tankf > 0 && tankf <1700)
{
tankf = tankf_;
}
else
{
cerr << "FULLTANK!"<< endl;
}
if( frate > 0 && frate <10)
{
frate = frate_;
}

else
{
cerr << "FUELRATE!"<< endl;
}
if( massl > 0 && massl <900)
{
massl = massl_;
}
else
{
cerr << "LANDERMASS!"<< endl;
}
if( thrust > 0 && thrust < 10)
{
thrust = thrust_;
}
else
{
cerr << "THRUST!"<< endl;
}
if( fuelconsum > 0 && fuelconsum < 10)
{
fuelconsum = fuelconsum_;
}
else
{
cerr << "FUELCONSUMPTION!"<< endl;
}
}
float lunar_lander::vvel()
{
return vvel_;
}
int lunar_lander::landed()
{
if (alt_<=0)
return 1;
return 0;
}
// CORRECTS IF TIME GOES BELOW ZERO
float lunar_lander::time(float q)
{
time_ = 0.0;
time_ ++;
if (time_ <= 0.0)
{
time_ = 0.0;
}
}
void lunar_lander::time()
{
for(int  z = 0.0; z < 5000; ++z)
time_++;
}
// RETRIEVES ALTITUDE
const float lunar_lander::getalt()
{
float qu;
for(int i = 0; i <1; ++i)
time_ = i;
qu = vvel_* time_;
//qu = time_ * ( thrust_/massl_ - 1.62);
frate_ -= (fuelconsum_ * qu);
alt_ -= qu;
return alt_;
}
// SETS INTIAL VALUE OF ALTITUDE
const float lunar_lander::getvvel()
{
float aw;
if (tankf_<=0)
{
tankf_=0;
frate_=0;
}
for(int i = 0; i < 1;++i)
time_++;
aw = vvel_* time_;
return aw;
}
// SETS INTIAL VALUE OF VELOCITY
const float lunar_lander::gettankf()
{

return tankf_;
}
const float lunar_lander::getfrate()
{
return frate_;
}
const float lunar_lander::getmassl()
{
return massl_;
}
const float lunar_lander::getthrust()
{
return thrust_;
}
 
const float lunar_lander::getfuelconsum()
{
return fuelconsum_;
}
float lunar_lander::frate(float t)
{
for(float i = 0.0; i < 1; ++i)
frate_ = t;
return frate_;
}
float thrust = 5000;
float alt = 1000;
float frate = 0;
float vvel_ = 5;
float tankf = 1700;
const float massl = 900;
const float fuelconsum = 10;

the program is succcessfully compiled. However, the value is not what I want
this is the sample run

Hey, this is starfleet, your orders are to safely land this ship with a
velocity greater than 5good luck captain

Altitude is 1000
Fuelleft 900
Thrust 3.21412e-040
Velocity is 0

it repeat over again and don't change the value as I wanted... help me please

#include "magic.h"
#include <conio.h>
#include <iostream>
using namespace std;
int main()

{
float throttle;
float frate_;
const float time = 10000;
float vvel_ = 5;
cout << "Hey, this is starfleet, your orders are to safely land this ship"
<< " with a " << endl << "velocity greater than " << vvel_
<< "good luck captain "<< endl << endl;

lunar_lander s(1000.0, 0.0, 10.0,900.0,0.0,5000.0,900.0);
while(s.getalt() > 0)
{

cout <<"Altitude is " << s.getalt() << endl;
cout <<"Fuelleft " << s.getmassl() << endl;
cout <<"Thrust " << s.frate(throttle/10) << endl;
cout <<"Velocity is " <<s.vvel() << endl;
cin >> throttle;
}
getch();
}
// FILE MAGICS.H
 
#ifndef LUNAR_LANDER
#define LUNAR_LANDER
using namespace std;
class lunar_lander
{
public:

lunar_lander(float, float, float, float, float, float, float);

void setLunar(float alt, float vvel, float tankf, float frate, float massl, float thrust, float fuelconsum);

// ALTITUDE AND ACCESSOR

const float getalt();

// VERTICAL SPEED AND ACCESSOR

float vvel();

const float getvvel();
// FUEL IN TANK AND ACCESSOR

const float gettankf();

// FUEL FLOW RATE AND ACCESSOR
float frate(float);
const float getfrate();

// LANDER MASS AND ACCESSOR
const float getmassl();
// LANDER THRUST AND ACCESSOR
const float getthrust();
// MAX FUEL CONSUMPTION RATE AND ACCESSOR
const float getfuelconsum();
// WHEN LUNAR LANDS
int landed();
// TIME
float time(float);
void time();
private:
float alt_;
int count;
float vvel_;
float tankf_;
float frate_;
float fuelconsum_;
float thrust_;
float massl_;
float time_;
};
#endif
#include "magic.h"
#include <iostream>
using namespace std;
lunar_lander::lunar_lander(float a, float vs, float fl, float t, float fr, float thr, float ml)
{
alt_ = a;
vvel_ = vs;
fuelconsum_ = fl;
tankf_ = t ;
frate_ = fr;
thrust_ = thr;
massl_ = ml;
}
void lunar_lander::setLunar(float alt, float vvel, float tankf, float frate, float massl, float thrust, float fuelconsum)
{
if(alt >0 && alt <1000)
{
alt = alt_;
}
else
{
cerr << "What" << endl;
}
if( vvel > 0 && vvel <5400)
{
vvel = vvel_;
}
else
{
cerr << "VELOCITY!"<< endl;
}
if(tankf > 0 && tankf <1700)
{
tankf = tankf_;
}
else
{
cerr << "FULLTANK!"<< endl;
}
if( frate > 0 && frate <10)
{
frate = frate_;
}

else
{
cerr << "FUELRATE!"<< endl;
}
if( massl > 0 && massl <900)
{
massl = massl_;
}
else
{
cerr << "LANDERMASS!"<< endl;
}
if( thrust > 0 && thrust < 10)
{
thrust = thrust_;
}
else
{
cerr << "THRUST!"<< endl;
}
if( fuelconsum > 0 && fuelconsum < 10)
{
fuelconsum = fuelconsum_;
}
else
{
cerr << "FUELCONSUMPTION!"<< endl;
}
}
float lunar_lander::vvel()
{
return vvel_;
}
int lunar_lander::landed()
{
if (alt_<=0)
return 1;
return 0;
}
// CORRECTS IF TIME GOES BELOW ZERO
float lunar_lander::time(float q)
{
time_ = 0.0;
time_ ++;
if (time_ <= 0.0)
{
time_ = 0.0;
}
}
void lunar_lander::time()
{
for(int  z = 0.0; z < 5000; ++z)
time_++;
}
// RETRIEVES ALTITUDE
const float lunar_lander::getalt()
{
float qu;
for(int i = 0; i <1; ++i)
time_ = i;
qu = vvel_* time_;
//qu = time_ * ( thrust_/massl_ - 1.62);
frate_ -= (fuelconsum_ * qu);
alt_ -= qu;
return alt_;
}
// SETS INTIAL VALUE OF ALTITUDE
const float lunar_lander::getvvel()
{
float aw;
if (tankf_<=0)
{
tankf_=0;
frate_=0;
}
for(int i = 0; i < 1;++i)
time_++;
aw = vvel_* time_;
return aw;
}
// SETS INTIAL VALUE OF VELOCITY
const float lunar_lander::gettankf()
{

return tankf_;
}
const float lunar_lander::getfrate()
{
return frate_;
}
const float lunar_lander::getmassl()
{
return massl_;
}
const float lunar_lander::getthrust()
{
return thrust_;
}
 
const float lunar_lander::getfuelconsum()
{
return fuelconsum_;
}
float lunar_lander::frate(float t)
{
for(float i = 0.0; i < 1; ++i)
frate_ = t;
return frate_;
}
float thrust = 5000;
float alt = 1000;
float frate = 0;
float vvel_ = 5;
float tankf = 1700;
const float massl = 900;
const float fuelconsum = 10;

the program is succcessfully compiled. However, the value is not what I want
this is the sample run


it repeat over again and don't change the value as I wanted... help me please

help me please

I dunno, 70 posts, and you've managed to figure out code tags.
But it's still unindented crap which is hard to read.

Translation - you're being ignored.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.