If-else Statements

...
Last edited on
closed account (4Gb4jE8b)
you'd probably want to use switch statements here

if (purchaseCost > 1000.00 && purchaseCost < 5000.01){
shippingCharge = 15.00;
}

else {
if (purchaseCost < 5000.00){
shippingCharge = 20.00;
}
see the error?
Last edited on
I thought about trying switch statements, but I thought you couldn't use them for doubles. Thanks for pointing out the wrong symbol used though!

Also, that didn't fix it. Is there a way to get my format working with if-else statements? That's currently what I'm reading about and I'm just trying to build one of the larger systems so I can understand it. (I'm FAR better at reading code than writing it!)
Last edited on
closed account (4Gb4jE8b)
I'm working directly with your code. as soon as i figure out exactly what's up i'll post
Okay, I will keep looking too!

I think I also tried putting an *if statement* before the assignment of 0 to shippingCharge, but it changed nothing.

So the problem definitely isn't the 0.00. I removed it and it still came out as 0.00, so it seems that it's just not registering the numbers that are input.
Last edited on
I'd suggest that maybe you change the style of your if/elses, but that's not the problem. Look carefully at line 41... do you have the wrong equals?

-Albatross
I assume you're talking about line 42? I thought that if you were checking if a value were equal to another you had to use double =, whereas = assigns a value to a data type?
closed account (4Gb4jE8b)
ooooooooooh i figured it out. I hate it when that happens,
if (shippingCharge = 0.00) assigns equal
if (shippingCharge == 0.00) checks if it's equal
Last edited on
I mean line 41. Look carefully. You have a single =, which as you correctly stated, is the assignment operator. :)

-Albatross
You sir/madame, are a genious. Sorry, Albatross, I have commentary I didn't post in the forum message. Mostly to remind myself of what the project was for in VS2010. My bad for looking at the wrong line 41. :) Thank you both!
Last edited on
closed account (4Gb4jE8b)
oh, albatross beat me to it :P
Topic archived. No new replies allowed.