Well I found a way. For some reason it wouldn't compile unless i made a new block at then end with nothing in it, but it worked. Here it is:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
float fuel, mean;
float flight_time,dist,ascent_time,ascent_fuel,alt,level_time,descent_fuel,
descent_time,level_flight,total_fuel,level_fuel,m,f;
void get_fuel ( float&f, float&m, float alt);
get_fuel (fuel, mean, alt);
cout<<"fuel consumed"<<fuel;
cout<<"mean fuel consumed"<<mean;
cout<<"enter distance";
cin>>dist;
flight_time = dist/300;
cout<<flight_time;
ascent_time = (alt/1000)/60;
cout<<"the ascent time is"<<ascent_time;
descent_time = (alt/1000)/60;
cout<<"the decent time is"<<descent_time;
level_time = flight_time -(ascent_time+descent_time);
cout<<"the level out time is"<<level_time;
descent_fuel = mean* descent_time*0.9;
cout<<"Fuel consumption for descent was"<<descent_fuel;
ascent_fuel = mean* ascent_time*1.4;
cout<<"Fuel consumption for ascent was"<<ascent_fuel;
level_fuel = fuel* level_time;
cout<<"Fuel consumption for level flight"<<level_fuel;
total_fuel = ascent_fuel + level_fuel;
cout<<"The total fuel consumption is "<<total_fuel;
system("PAUSE");
return 0;
};
void get_fuel(float&f, float&m, float alt)
{
cout<<"What Altitude";
cin>> alt;
{
if (alt== 5000)
{
f=680;
m=814;
}
if (alt == 10000)
{
f=615;
m=750;
{
if (alt == 15000)
{
f=545;
m=680;
}
if(alt == 20000)
{
f=475;
m=615;
}
if(alt == 25000)
{
f=410;
m=545;
}
if (alt == 30000)
{
f=340;
m=475;
}
if (alt == 35000)
{
f=270;
m=410;
}
if (alt ==40000)
{
f=200;
m=475;
}
}
};
}
};
You have to make the output look a little neater though, it was all scrunched up together.