|
-
Oct 22nd, 2002, 01:50 PM
#1
Thread Starter
Hyperactive Member
if help
ok im getting errors when i try this saying that (Boolean,int) are not allowed??? first if works fine all the else ifs are %^&*ed up ?
if (intSetPieces > 0 || intSetPieces <= 199)
{
dblPay = .50D;
}
else if (intSetPieces = 200 || intSetPieces <= 399)
{
dblPay = .55D;
}
else if (intSetPieces = 400 || intSetPieces <= 599)
{
dblPay = .60D;
}
else if (intSetPieces = 600 || intSetPieces <= 100)
{
dblPay = .65D;
}
else
{
intError = 1;
strError = "Error With Calculating Payment";
}
-
Oct 22nd, 2002, 03:32 PM
#2
Hyperactive Member
You need double equal signs to compare. Otherwise you're asigning a value to a variable
-
Oct 22nd, 2002, 10:43 PM
#3
Dazed Member
Posted by marnitzg
You need double equal signs to compare. Otherwise you're asigning a value to a variable
I think that is what he wants to do. I couldnt see using the equals operator by itself. I wouldn't be a statement.
-
Oct 23rd, 2002, 04:18 PM
#4
In the if statements, not in the blocks:
Code:
else if (intSetPieces = 200 /* wrong */ || intSetPieces <= 399)
{
dblPay = .55D; // ok
}
Oh, btw you should use logical and (&&) not or (||) in the first if, else it catches everything (every number is greater 0 or less than 199).
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 23rd, 2002, 11:23 PM
#5
Dazed Member
Oh yeah. right. I just took a quick look at the the first conditional statement sorry. Yeah 308holes CornedBee is right. Using the short circut operator || if the first condition equates to true the second condition will just be skiped so intSetPieces could end up being more than 199 clearly not what you want.
-
Oct 24th, 2002, 07:03 PM
#6
Hyperactive Member
-
Oct 24th, 2002, 10:45 PM
#7
Dazed Member
Sorry marnitzg. I didnt see the assignment operator in the second conditional statement so i thought you were refering to the line dblPay = .50D; meaning it should be dblPay == .50D;
-
Oct 25th, 2002, 03:52 PM
#8
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|