0

Help with a Code

https://code.sololearn.com/cl0mF5CspJRZ/?ref=app need help figuring out what I've done wrong and how to fix. new to this, so I've been unable to find the error with a lot of tweaking. it's supposed to work like a guess the number game! Any advice would be appreciated.

14th Dec 2017, 3:12 PM
Jason Bloom
Jason Bloom - avatar
3 Respuestas
+ 8
// This is how your code is supposed to be after the main() method, please replace your code with the code below. The input part may not work well in the Code Playground, run it on a PC for a better experience! :) scan = new Scanner(System.in); rand = new Random(); System.out.println("Please enter the max guess:"); maxValue = scan.nextInt(); number = rand.nextInt(maxValue); System.out.println("Please enter your guess"); while (guess != number) { guess = scan.nextInt(); if (guess > number) { System.out.println("Your guess is too high!"); } else if (guess < number) { System.out.println("Your guess is too low!"); } else { System.out.println("You win!"); } }
14th Dec 2017, 3:39 PM
Dev
Dev - avatar
+ 4
https://code.sololearn.com/cBc4BrfkxQvt/?ref=app I have made the changes.. there were lots of syntax errors.. and I have removed the while condition because here in sololearn the input prompt will not appear after every guess... so u need to rerun the program to play again
14th Dec 2017, 3:38 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
thanks guys!
14th Dec 2017, 3:47 PM
Jason Bloom
Jason Bloom - avatar