1234567891011121314151617181920212223242526 |
- /**
- * Created by iyasuwatts on 10/17/17.
- */
- import java.util.*;
- public class Main {
- public static void main(String[] args){
- Scanner keyboard = new Scanner(System.in);
- boolean isCorrect = false;
- int n=0;
- while(isCorrect==false) {
- System.out.println("Guess a mystery number between 0 and 10!");
- int randNumber=(int)(Math.random()*10+1);//generating a random number
- int number = keyboard.nextInt();//user input
- if(number == randNumber) {
- System.out.println("correct guess");
- isCorrect = true;
- }else if(number>=randNumber){
- System.out.println("too large");
- } else{
- System.out.println("too small");
- }
- n++;
- }
- System.out.println(n);
- }
- }
|