• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in Simple Dot Com Game

 
Spandan Pandey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did some corrections and the .java file compiled without any error but the error began in the output
Here is my code..Is My conversion of the int random numbers into string and using in checkyourself method is wrong?If not then why the output error..the program gets stuck asking-enter the number perpetually.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15356
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're doing some strange things in lines 49 to 56.

In line 49, you're generating a random number. You're not using that anywhere. In lines 51 to 56, you are adding strings that contain "randomNum", "randomNum+1" and "randomNum+2" to a list. Note that those are literally those strings - it looks like you expect that these strings will be evaluated to contain the random number, plus one or two, but that is not what happens. If you use a variable name in a string literal, it's not going to be evaluated automatically.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic