JAVA猜数字的小程序

  JAVA猜数字的小程序!

  注册游戏账号点击图片进入游戏百家乐,网上真钱棋牌,龙虎游戏

  public class GuessNumber {

  public static void main(String[] args) {

  System.out.println("给你一个0至100之间的整数,请猜测这个数");

  //随机生成一个0至100之间的随机整数

  int realNumber=(int)Math.round(Math.random()*100);

  //从键盘上读入你的猜测;

  System.out.print("请输入你的猜测:");

  int yourGuess=System.in.read();

  //是否猜对的标识

  boolean isRight=false;

  //循环校验,直到猜对了为止

  while(!isRight){

  if(yourGuess > realNumber){

  System.out.print("猜大了,再输入你的猜测:");

  yourGuess= System.in.read();

  }

  else if(yourGuess < realNumber){

  System.out.print("猜小了,再输入你的猜测:");

  yourGuess=System.in.read();

  }

  else{

  isRight=true;

  System.out.print("恭喜你,猜对了");

  }

  }

  }

  }

  JAVA猜数字的小程序!

Comments

Popular posts from this blog

PNG黄金入场券游戏技巧,PNG黄金入场券游戏规则介绍

NBA中什么叫乐透区

PP亚特兰蒂斯女王游戏技巧,PP亚特兰蒂斯女王游戏规则介绍