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 guess = 5;
- int tries = 0;
- System.out.println("I have chosen a number between 1 and 10. Try to guess it.");
- System.out.println("Your guess: ");
- int num = keyboard.nextInt();
- tries++;
- do{
- System.out.println("That is incorrect. Guess again.");
- System.out.println("Your guess: ");
- num = keyboard.nextInt();
- tries++;
- }while (num != guess);
- System.out.println("Congratulations it only took you " +
- tries + " tries");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement