/** * Created by iyasuwatts on 10/17/17. */ import java.util.Scanner; import java.util.Random; public class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); int randNumb; int guess; int numbAtempts=0; Random genRand = new Random(); randNumb= genRand.nextInt(100) +1; int lastInput; System.out.println ("I'm thinking off a number between 1 to 100?:"); guess=input.nextInt(); lastInput=guess; while (guess !=randNumb ){ if (guess> randNumb){ System.out.println("Your number is too BIG "); guess=input.nextInt(); numbAtempts+=1; } else { System.out.println("Your number is too SMALL"); guess=input.nextInt(); numbAtempts+=1; } } System.out.println(randNumb + " is the right number and it only took you" +" "+ (numbAtempts + 1) + " tries"); } }