Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement