Ahoy there,
Thanks for taking the time to read this. I'm in a programming class and this is my first adventure into the subject.
I'm working on a code that is supposed to be a number guessing game.
Here's where I am at so far
import java.util.*; import java.io.*; public class number_guessing_game { public static void main (String[] args) { BufferedReader input = new BufferedReader (new InputStreamReader(System.in)); double attempts = 0; double random = 0; double guess = 0; String go = ""; Random generator = new Random (); int answer = generator.nextInt(10) + 1; while(go.equals("yes")) { System.out.println("How many chances do you want? "); try { attempts = Double.parseDouble(input.readLine()); } catch (IOException E) { System.out.println(E); } System.out.println("What's the magic number? (1-10)? "); try { guess = Double.parseDouble(input.readLine()); } catch (IOException E) { System.out.println(E); } if (guess == answer) { System.out.println("Congrats! You're guess is right"); } else if (guess != answer) { System.out.println("Sorry, that is not correct! Would you like to try again?"); try { go = input.readLine(); } catch (IOException E) { System.out.println(E); } } } } }
I exit nano, compile with no exceptions, but when I go to run it, I just get the next line:
student21@slisdl1:~/LS590/Labs/Lab4> javac number_guessing_game.java
student21@slisdl1:~/LS590/Labs/Lab4> java number_guessing_game
student21@slisdl1:~/LS590/Labs/Lab4>
Any ideas? I've gone over it a ton and still can't put my finger on the problem.
Thank you in advance for any suggestions