use Random Class randomly generates a 0-100 Number within , Let people guess .
import java.util.Scanner; import java.util.Random; public class game { public
static void main(String[] args) { Random a = new Random(); int data =
a.nextInt(100)+1; Scanner input = new Scanner (System.in); while(true) {
System.out.println(" Guess how old (0~100):"); int nc =input.nextInt(); if(nc<0 || nc>100)
{ System.out.println(" The number entered is not in 0-100 within "); }else if(nc<data){
System.out.println(" Guess it's small "); }else if(nc>data) { System.out.println(" Guess big "); }else
{ System.out.println(" Congratulations !"); break; } } input.close();} }

Technology