• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Help with my nested if statement

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys
I have been trying to figure out why this line of code never looks at the else if part of the if statement. I have been trying a long time now and no luck maybe someone can figure it out. This is not the exact code I edited it so it would make sense out of context, but as far as I can tell y is ++ but the else if is never run in the loop but all the rest of it is running correctly. Any help would be great.
 
Ranch Hand
Posts: 144
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
else if will run if and only if first if condition is false so please check your logic.
 
Bryce Heath
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Thanks for the reply. I'm glad you took the time to look at this. Funny how such a simple mistake can take so long to figure out.
 
Marshal
Posts: 77168
370
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would do well to write your logic down as pseudo-code on a sheet of paper before trying to commit it to silicon. That might have prevented that mistake.
 
reply
    Bookmark Topic Watch Topic
  • New Topic