import java.util.Scanner;
import java.util.Random;
class KnockRedBox
{
public static void main(String[] args)
{
Random r = new Random();
System.out.println("抢红包啦!一共有5个红包,序号分别为1~5先抢先得,请输入序号抢红包:");
int a = 101;
int x1 = r.nextInt(a);
int x2 = r.nextInt(a-=x1);
int x3 = r.nextInt(a-=x2);
int x4 = r.nextInt(a-=x3);
int x5 = r.nextInt(a-=x4);
int x6 =(a-=x5-1);
//System.out.println(x1);
while(true){
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
//String key = sc.nextLine();
if(i == 1)
{
System.out.println("恭喜你获得了"+x1+"元");
}
else if(i == 2)
{
System.out.println("恭喜你获得了"+x2+"元");
}
else if(i == 3)
{
System.out.println("恭喜你获得了"+x3+"元");
}
else if(i == 4)
{
System.out.println("恭喜你获得了"+x4+"元");
}
else if(i == 5)
{
System.out.println("恭喜你获得了"+x5+"元");
}
else if(i == 6)
{
System.out.println("恭喜你获得了"+x6+"元");
}
else
{
System.out.println("没有那么多红包,给你一个"+0+"元红包吧");
}
}
}
}
|
|