2 Replies - 595 Views - Last Post: 09 May 2008 - 01:53 AM Rate Topic: -----

#1 warchilo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 15-January 07

Need help with if statement

Posted 08 May 2008 - 09:19 AM

Hello guys, I'm trying to revise for a basic programming test next week and I have hit a brick wall with one of the example programs. Basically I have an if statement with two conditions to check but the second condition isn't getting checked so the program isn't entering the if statement and the result is an answer I dont want.

if ((DaysSinceDebited[counter]<30)||(Balance[counter]<1000))
		{
			interest = ((Balance[counter]/100)*3);
		}



the problem I am having is that the the second part isn't being checked so if the first part doesn't come up true the if statement is being ignored. Any help would be appreciated as I have been trying to do this for hours now. If you need more of the code to help me out let me no and I'll put it straight up.

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Need help with if statement

#2 realNoName  Icon User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 343
  • Joined: 04-December 06

Re: Need help with if statement

Posted 08 May 2008 - 09:56 AM

so you need both conditions to be true? if so then you need to use and 'and' not 'or'

if ((DaysSinceDebited[counter]<30) && (Balance[counter]<1000))
		{
			interest = ((Balance[counter]/100)*3);
		}

Was This Post Helpful? 0
  • +
  • -

#3 warchilo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 15-January 07

Re: Need help with if statement

Posted 09 May 2008 - 01:53 AM

View PostrealNoName, on 8 May, 2008 - 09:56 AM, said:

so you need both conditions to be true? if so then you need to use and 'and' not 'or'

if ((DaysSinceDebited[counter]<30) && (Balance[counter]<1000))
		{
			interest = ((Balance[counter]/100)*3);
		}


Thank you, I keep making simple errors like this. you wouldn't believe the amount of time i wasted trying to use 'or'.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1