• Post Reply Bookmark Topic Watch Topic
  • New Topic

++ Operator not working with If else statement  RSS feed

 
Muzafar Ali
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am using ++ operator for recording wrong entries by user in else but it is not working, it is not recording user mistakes why?
here is the program

 
Radi Hadzhiyski
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've copied your code into my eclipse and everything seems to be fine.

if i am wrong more than 1 times it says Game over (but of course after all questions are done)

if i make a mistake on the first two question i become the next 4 questions anyway but even if answer them right i see the Game over because of the first two question
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider using a loop.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know it is not recording user mistakes?

Note that in line 79 you are checking if 'wrong' has the value 2. What happens if the user makes 1 mistake? Or 3, or 4?
 
Radi Hadzhiyski
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it should be


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!