Please alittle help-- if/else
I've written this program a few different ways but it is not seeing the function in C++6.0.
I need to have the program identify when I have;
exterior(1),interior(2);
If(gallons=1.0||andgallons<=3.0)
cout>>exterior(1)price||interior(2)price;
Maybe because I have two different paint values I want to input and only one gallon amount am confusing the program?
Exterior price is lower then interior. I don't know truthfully this is the first time working with if / else. && ||. If I didn't make my self to clear please let me know. Thank -you.
Re: Please alittle help-- if/else
Quote:
Originally posted by jill
I've written this program a few different ways but it is not seeing the function in C++6.0.
I need to have the program identify when I have;
exterior(1),interior(2);
If(gallons=1.0||andgallons<=3.0)
cout>>exterior(1)price||interior(2)price;
I don't know your whole program, but ...|| andgallons <=... Are you sure andgallons is the variable name? Looks odd, like maybe you're trying to do an || and a &&. But, it's a legal name if that's what you have.
Should be cout <<, not cout >>. That whole line looks funky. The parantheses look like a function call, and you can't cout an or statement. You can cout exterior by itself or interior by itself, but your if statement should have taken care of the choice. Exterior(1)price doesn't seem right either. if you're cout'ing the result of a function call, the call would be something like cout << exterior(price), or similar.
exterior/interior to Brown Drake
Yes I did catch some of my earlier mistakes today. Ok here goes
There is a list of prices;
Exterior Interior
1 to3 =16.75 16.26
4 to7 =15.85 15.10
this goes on a few more steps but thats the general idea;
if(numberofgallons==1.0<=3.0);
cout<< Know how do I get this to see exterior price and the interior price.
I know this is my problem because I have no errors and 4 warnings the warnings are in this section.
Maybe I should change;
int// (to)// exterior price, interior price. But am not sure how.
This is assignment I'd like to work it through but I have spent to many hours on it now I have to get through this thanks.
Re: exterior/interior to Brown Drake
Quote:
Originally posted by jill
Yes I did catch some of my earlier mistakes today. Ok here goes
There is a list of prices;
Exterior Interior
1 to3 =16.75 16.26
4 to7 =15.85 15.10
this goes on a few more steps but thats the general idea;
if(numberofgallons==1.0<=3.0);
cout<< Know how do I get this to see exterior price and the interior price.
This is not right. I think what you want is:
Code:
int numGallons;
double price;
bool exterior;
// Insert code to set these variables to something
if (numGallons <= 3)
if (exterior)
price = 16.75;
else
price = 16.26;
else if (numGallons >= 4 && numGallons <= 7)
if (exterior)
price = 15.85;
else
price = 15.10;
cout << price << endl;
There are other ways to do it, but that'll work. Post your own code if you need more help.
Quote:
Maybe I should change;
int// (to)// exterior price, interior price. But am not sure how.
Not sure what you mean here.