1234567891011121314151617181920212223242526
  1. /**
  2. * Created by iyasuwatts on 10/17/17.
  3. */
  4. import java.util.*;
  5. public class Main {
  6. public static void main(String[] args){
  7. Scanner keyboard = new Scanner(System.in);
  8. boolean isCorrect = false;
  9. int n=0;
  10. while(isCorrect==false) {
  11. System.out.println("Guess a mystery number between 0 and 10!");
  12. int randNumber=(int)(Math.random()*10+1);//generating a random number
  13. int number = keyboard.nextInt();//user input
  14. if(number == randNumber) {
  15. System.out.println("correct guess");
  16. isCorrect = true;
  17. }else if(number>=randNumber){
  18. System.out.println("too large");
  19. } else{
  20. System.out.println("too small");
  21. }
  22. n++;
  23. }
  24. System.out.println(n);
  25. }
  26. }