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;
}
}
没有写注释的习惯,以后要改改了.
|
|