Advertisement
lol1234561

Untitled

Mar 8th, 2023
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner keyboard = new Scanner(System.in);
  5.         int Number = 10;
  6.         int tries = 0;
  7.         System.out.println("I choose a number between 1 and 10. Try to guess it. ");
  8.         System.out.println("Your guess: ");
  9.         int guess = keyboard.nextInt();
  10.  
  11.         while(guess != Number){
  12.             System.out.println("That is incorrect. Guess Again.");
  13.             System.out.println("Your guess: ");
  14.             guess = keyboard.nextInt();
  15. tries++;
  16.         }
  17. if(guess == Number){
  18.     System.out.println("That's right! You're a good guesser.");
  19.     System.out.println("It only took you " +
  20.             tries + " tries.");
  21. }
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement