Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- int pin = 3;
- int numberofguesses=0;
- int entry = 0;
- System.out.println("\nI have chosen a number between 1 and 10");
- do{
- System.out.print("Your guess: ");
- entry = keyboard.nextInt();
- if ( entry == pin) {
- } else {
- System.out.println("That is incorrect. Guess again!");
- }
- numberofguesses++;
- }
- while (entry != pin);
- System.out.println("You are correct!");
- System.out.println("It only took you " + numberofguesses + " guesses");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement