本帖最后由 linda2906881980 于 2015-5-6 23:36 编辑
import java.util.Scanner;
class MathGame
{
public static void main(String[] args)
{
int number = (int)(Math.random()*100+1);
System.out.println("请输入一个数");
while (true)
{
Scanner s=new Scanner(System.in);
int getnumber=s.nextInt();
if (getnumber>number)
{
System.out.println("您输入的数"+getnumber+"大了");
}
else if (getnumber<number)
{
System.out.println("您输入的数"+getnumber+"小了");
}
else
{
System.out.println("恭喜你中奖了,哈哈");
break;
}
}
}
}
|
|