public class Guessnumbers { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Hello World"); try (Scanner in = new Scanner(System.in)) { int number=(int)(Math.random()*100+1); int a; int count=0; do { a = in.nextInt(); count=count+1; if(a>number) { System.out.println("有点大了呢"); } else if (a<number) { System.out.println("小了一点呢"); } } while(a!=number); System.out.println("恭喜您猜对了,您一共猜了"+count+"次"); } }}