AaronMT Posted October 24, 2004 Share Posted October 24, 2004 How do I program this If (*grosspay is between 100 and 199 - subtract $2) Which logical operators do I need to use, for a range of numbers? Thanks Link to comment Share on other sites More sharing options...
0 blik Posted October 24, 2004 Share Posted October 24, 2004 if (grosspay > 100) && (grosspay < 199) { grosspay == grosspay - 2; } Link to comment Share on other sites More sharing options...
0 hdood Posted October 24, 2004 Share Posted October 24, 2004 This will deduct 2 from grosspay if grosspay is equal to or higher than 100, and lower or equal to 199: if((grosspay > 99) && (grosspay < 200)) grosspay -= 2; Link to comment Share on other sites More sharing options...
0 Andareed Posted October 24, 2004 Share Posted October 24, 2004 @Bliksem: == does not assign anything, it compares. @hdood: if grosspay == 99.5, your statement will return true but 99.5 < 100 if( (grosspay > 100) && (grosspay < 199) ) { grosspay -= 2; } If you want inclusive, use >= and <= in place of > and < respectively. Link to comment Share on other sites More sharing options...
Question
AaronMT
How do I program this
If (*grosspay is between 100 and 199 - subtract $2)
Which logical operators do I need to use, for a range of numbers?
Thanks
Link to comment
Share on other sites
3 answers to this question
Recommended Posts