hey guys, so quarter ends tmw and all programs are due in my C++ class. I have them all done except for one, where we have to write a class called gas station.....so i was wondering if someone who knows c++ could help me out and tell me what's wrong with this?? it won't return the right values, just some random number**i'm pretty sure the thing that runs it is accurate**
sorry this is so long, but thanks!
and yes, i kno im quite dumb when it comes to c++
CODE
class GasStation
{
public:
int gallonsLeft;
int totalGallonsSold;
double mySellPrice;
double myCost;
double myProfit;
int myGallonsSold;
double tempProfit;
double fillerProfit;
double myGrossProfit;
GasStation()
{
}
void GasStation::Reset(void)
{
mySellPrice=0;
myCost=0;
myProfit=0;
myGallonsSold=0;
}
void GasStation::setGallonsSold(int c)//sets the number of gallons sold
{
myGallonsSold=c;
}
void GasStation::setSellPrice(double a)//sets the selling price
{
mySellPrice=a;
}
void GasStation::setCost(double B)//sets the cost per gallon that the station pays
{
myCost=b;
}
void GasStation::findGallonsLeft()//finds the number of gallons left when starting with 200
{
gallonsLeft=gallonsLeft-myGallonsSold;
}
void GasStation::findTotalGallonsSold()//finds the total number of gallons sold
{
totalGallonsSold=200-gallonsLeft;
}
void GasStation::findTempProfit()//finds the profit from one sale
{
tempProfit=myGallonsSold*mySellPrice;
}
void GasStation::findFillerProfit()//junk that i need for gross profit
{
fillerProfit=999999-tempProfit;
}
void GasStation::findGrossProfit()//finds the gross profit
{
myGrossProfit=999999-fillerProfit;
}
void GasStation::findNetProfit()//finds the net profit
{
myProfit=myGrossProfit-200*myCost;
}
int GasStation::getTotalGallonsSold()//returns the total number of gallons sold
{
return totalGallonsSold;
}
double GasStation::getGrossProfit()//returns the gross profit
{
return myGrossProfit;
}
double GasStation::getNetProfit()//returns the net profit
{
return myProfit;
}
};
edit: remember to use code tags.
sorry this is so long, but thanks!
and yes, i kno im quite dumb when it comes to c++
CODE
class GasStation
{
public:
int gallonsLeft;
int totalGallonsSold;
double mySellPrice;
double myCost;
double myProfit;
int myGallonsSold;
double tempProfit;
double fillerProfit;
double myGrossProfit;
GasStation()
{
}
void GasStation::Reset(void)
{
mySellPrice=0;
myCost=0;
myProfit=0;
myGallonsSold=0;
}
void GasStation::setGallonsSold(int c)//sets the number of gallons sold
{
myGallonsSold=c;
}
void GasStation::setSellPrice(double a)//sets the selling price
{
mySellPrice=a;
}
void GasStation::setCost(double B)//sets the cost per gallon that the station pays
{
myCost=b;
}
void GasStation::findGallonsLeft()//finds the number of gallons left when starting with 200
{
gallonsLeft=gallonsLeft-myGallonsSold;
}
void GasStation::findTotalGallonsSold()//finds the total number of gallons sold
{
totalGallonsSold=200-gallonsLeft;
}
void GasStation::findTempProfit()//finds the profit from one sale
{
tempProfit=myGallonsSold*mySellPrice;
}
void GasStation::findFillerProfit()//junk that i need for gross profit
{
fillerProfit=999999-tempProfit;
}
void GasStation::findGrossProfit()//finds the gross profit
{
myGrossProfit=999999-fillerProfit;
}
void GasStation::findNetProfit()//finds the net profit
{
myProfit=myGrossProfit-200*myCost;
}
int GasStation::getTotalGallonsSold()//returns the total number of gallons sold
{
return totalGallonsSold;
}
double GasStation::getGrossProfit()//returns the gross profit
{
return myGrossProfit;
}
double GasStation::getNetProfit()//returns the net profit
{
return myProfit;
}
};
edit: remember to use code tags.