im havin trouble with gettin this code to work...it will compile but im not gettin the results i want...
heres what the code looks like:
#include <iostream.h>
#include <iomanip.h>
const int MAX=10;
const int INPUT_SENTINEL=0;
int a,b,m,g,results;
void printheader();
void main ()
{
cout<<"***************************"<<endl;
cout<<"**Gas Calculation Program**"<<endl;
cout<<"***************************"<<endl;
cout<<endl<<endl;
cout<<"Please enter the starting mileage: ";
cin>>a;
cout<<"To stop the reading press 0 for miles and gallons....to see results type in results for miles."<<endl;
cout<<endl;
cout<<"What was your stopping point in miles: ";
cin>>m;
cout<<endl;
cout<<"How many gallons of gas did you need to travel this far: ";
cin>>g;
cout<<endl;
if ((m<0) && (g<0))
{
cout<<"Please enter in a positive integer for miles and gallons."<<endl;
}
else
if((m>0) && (g>0))
{
cout<<"To stop the reading press 0 for miles and gallons."<<endl;
cout<<endl;
cout<<"What was your stopping point in miles: ";
cin>>m;
cout<<endl;
cout<<"How many gallons of gas did you need to travel this far: ";
cin>>g;
cout<<endl;
}
return;
}
void printheader ()
{
cout<<endl;
cout<<setw(15)<<"Odometer"<<setw(5)<<"Odometer"<<s etw(5)<<"Fuel"<<setw(5)<<"Miles"<<setw(5)<<"Fuel"< <setw(5)<<"Miles"<<setw(5)<<"Mpg"<<setw(5)<<"Mpg"< <endl;
cout<<setw(15)<<"(begin)"<<setw(6)<<"(end)"<<setw( 8)<<"(tank)"<<setw(7)<<"(tank)"<<setw(7)<<"(trip)" <<setw(7)<<"(trip)"<<setw(7)<<"(tank)"<<setw(7)<<" (trip)"<<endl;
cout<<endl;
cout<<"Miles: "<<b<<endl;
cout<<"Gallons: "<<g<<endl;
cout<<endl;
cout<<setw(18)<<a<<setw(11)<<b<<setw(13)<<g<<setw( 9)<<endl;
}
i think the problem may be in the if else loop but im not totally sure....if anyone out there can help me send me a PM b4 950 am PST....thanks to those who could help