Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- int Number = 10;
- int tries = 0;
- System.out.println("I choose a number between 1 and 10. Try to guess it. ");
- System.out.println("Your guess: ");
- int guess = keyboard.nextInt();
- while(guess != Number){
- System.out.println("That is incorrect. Guess Again.");
- System.out.println("Your guess: ");
- guess = keyboard.nextInt();
- tries++;
- }
- if(guess == Number){
- System.out.println("That's right! You're a good guesser.");
- System.out.println("It only took you " +
- tries + " tries.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement