java 学习第五天--猜字游戏

断了今生、忘了曾经 提交于 2019-11-29 19:29:19
package javase24;

import java.util.Scanner;
public class GuessNumber {
	public static void main(String[] args) {
		int num =9;
		Boolean guess= true;
		while(guess) {
			System.out.println("请输入一个数字");
			
		
		 Scanner user= new Scanner(System.in);
		 String Guess= user.nextLine();
		 //解析字符串成为数字
		int userguess =Integer.parseInt(Guess);
		//判断
		if(userguess > 9){
			System.out.println("你猜的数字太大了");
		}else if(userguess < 9){
			System.out.println("你猜的数字太小了");
		}else{
			System.out.println("恭喜你!猜对了");
			guess=false;
		}
		//...........................
		
		}
	}	

}

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!