SHARE
TWEET

Untitled

a guest Oct 12th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         int gameNum = 0;
  2.         int[] gameData = new int[1];
  3.         int[] tempData = new int[gameData.length + 1];
  4.         WhileLoop:
  5.         while (true) {
  6.             Random rand = new Random();
  7.             int n = rand.nextInt(100) + 1;
  8.             int guesses = 1;
  9.             System.out.println(n);
  10.             while (true) {
  11.                 System.out.println("Enter your guess");
  12.                 int guess = myScanner.nextInt();
  13.                 guesses++;
  14.                 if (guess == n) {
  15.                     System.out.println("Correct");
  16.                     gameNum++;
  17.                     break;
  18.                 } else if (guess != n) {
  19.                     System.out.println("Try again. " + (guess > n ? "The number is lower" : "The number is higher"));
  20.  
  21.                 } else {
  22.                     System.out.println("Please enter a real number");
  23.  
  24.                 }
  25.             }
  26.            
  27.             for (int i = 0; i < gameData.length; i++) {
  28.                 tempData[i] = gameData[i];
  29.             }
  30.             System.out.println("Play again?");
  31.             String playAgain = myScanner.next();
  32.             if (playAgain.equalsIgnoreCase("No")) {
  33.                 break WhileLoop;
  34.             }
  35.         }
  36.         System.out.println("You played the game " + tempData.length + (gameNum < 1 ? " time." : " times"));
  37.         for (int i = 0; i < tempData.length; i++) {
  38.             int stats = tempData[i];
  39.            
  40.            
  41.         }    
  42.     }
  43. }
RAW Paste Data
Top