标题: 1-100猜数字游戏 [打印本页] 作者: 果蝇 时间: 2015-9-1 22:44 标题: 1-100猜数字游戏 import java.util.*;
class GuessNum{
public static void main(String[] args){
int bingo = random();
int count = 1;
//System.out.println(bingo);
Scanner sc = new Scanner(System.in);
while(true){
if (count != 1)
System.out.println("o(︶︿︶)o o(︶︿︶)o o(︶︿︶)o ");
System.out.println("The count is "+count+",please putin the number(for 1~100):");
int num = sc.nextInt();
if ( num == 0 ){
System.exit(0);
}else if ( num<bingo ){
System.out.println("The key is more bigger than the number. ");
}else if ( num>bingo){
System.out.println("The key is more smaller than the number.");
}else {
if (count<10){
System.out.println("Bingo!");
break;
}else{
System.out.println("Rihgt,but you are SB?");
break;
}
}
count++;
}
}
public static int random(){
int bingo = (int)(100*Math.random()-1);
//System.out.println(bingo);
return bingo;
}
}