SHARE
TWEET

Untitled

a guest Nov 19th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         int correct = 7;
  7.         int amoutOfGuess = 0;
  8.  
  9.         Scanner keyboard = new Scanner(System.in);
  10.         System.out.println("I have chosen a number between 1 and 10. Try to guess it");
  11.         System.out.println("Your guess: ");
  12.         int entry = keyboard.nextInt();
  13.         amoutOfGuess = amoutOfGuess + 1;
  14.  
  15.  
  16.         while (entry != 7){
  17.             System.out.println("That is incorrect. Guess again.");
  18.             System.out.println("Your guess: ");
  19.             entry = keyboard.nextInt();
  20.             amoutOfGuess = amoutOfGuess + 1;
  21.  
  22.         }
  23.         System.out.println("That's right. You're a good guesser");
  24.         System.out.println("It only took you "+amoutOfGuess+ " tries");
  25.  
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top