Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

a modified version of high/low guessing game  RSS feed

 
Nathan Bowers
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the application itself is supposed to be a guessing game of high/low where the answer is a randomly generated number and the user inputs a number the (guess) and depending on the answer it is either to high or to low and it loops until the user gets the right answer.

now i need to modify the game so that the game doesn't officially start (the guessing high/low in regards to the answer) until the user correctly guesses the right amount of digits as an example if the answer was 532 and the user puts in 325. Since the 325 has three digits and 532 has three digits then the guessing of high/low can begin otherwise if the user input was 32 and the answer was 532 at that point it would loop until the user inputs a number of three digits.

the issue i am having begins on line 59 and ends on line 71. i am not sure what the issue is did i not initialize the variable guess correctly? if not then how would i do it correctly? when i comment that portion out it compiles as it should. what am i doing wrong?

 
Carey Brown
Bartender
Posts: 2985
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lines 47-71 need to be enclosed in a method.
In the future please post any error messages. That will help us to help you.
 
Nathan Bowers
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tinkered with the code a little bit more and now i am getting this error NumberGuess.java:56: error: <identifier> expected UserGuess = Keyboard.nextInt();
i dont quite understand why i need to identify the variable UserGuess if it has already been defined as an int. or am i completely missing something here?

what i am supposed to do is write a method that receives an int and returns the number of digits lines 49 - 66

 
Carey Brown
Bartender
Posts: 2985
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:Lines 47-71 need to be enclosed in a method.
In the future please post any error messages. That will help us to help you.

You still haven't addressed this issue.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!