刚刚学习的小程序,感觉挺爽,希望有钱的捧个钱场,黑马币还不够,希望能赏个!
import java.util.Random;
import java.util.Scanner;
class Guessnumber2
{
public static void main(String[] args)
{
Random a = new Random();
int number = a.nextInt(100)+1;
while(true)
{
Scanner sc = new Scanner(System.in);
System.out.println("给个数呗!");
int guessnumber = sc.nextInt();
if(guessnumber>number)
System.out.println("亲,"+guessnumber+" 大了!");
else if (guessnumber<number)
System.out.println("亲,"+guessnumber+" 小了!");
else
{
System.out.println("你猜对了,请保持手机畅通,奥巴马总统近期联系您");
break;
}
}
}
}
|
|