import java.util.Random;
import java.util.Scanner;
public class 双色球系统 {
//中奖号码:
public static void main(String[] args) {
int [] arr = new int[7];
Random r = new Random();
for (int i = 0; i < 6;) {
int a1 = r.nextInt(33)+1;
boolean b1 = mun(arr,a1);
if (b1==false){
arr[i] = a1;
i++;
}
}
arr[6] = r.nextInt(16)+1;
System.out.println("中奖号码是: ");
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
//我的号码:
Scanner sc = new Scanner(System.in);
int []c1 = new int[7];
for (int i = 0; i < 6;) {
System.out.println("请输入您的红球号码第" +(i+1) +"位数是:");
int b = sc.nextInt();
if (b>=1&&b<=33){
boolean c = mun(c1,b);
if(c == false){
c1[i] = b;
i++;
}else{
System.out.println("红球号码" + (i+1) +"输入重复错误,请重新输入");
}
}else{
System.out.println("红球号码"+ (i+1) +"输入范围错误,请重新输入");
}
}
System.out.println("请输入您的蓝球号码:");
for (int i = 0; i < 1;) {
int d1 = sc.nextInt();
if(d1>=1&&d1<=16){
c1[6] = d1;
i++;
}else{
System.out.println("篮球号码输入范围错误,请重新输入");
}
}
System.out.println("我的双色球号码是:");
for (int i = 0; i < c1.length; i++) {
System.out.print(c1[i] + " ");
}
//中奖金额
int n = 0;
int m = 0;
for (int i = 0; i < 6; i++) {
for (int i1 = 0; i1 < 6; i1++) {
if(arr[i]==c1[i1]){
n +=1;
}
}
}
if (arr[6]==c1[6]){
m +=1;
}
if(n==6&&m==1){
System.out.println("恭喜获得一等奖,获得 1000万 元");
}else if(n==5&&m==0){
System.out.println("恭喜获得二等奖,获得 500万 元");
}else if(n==5&&m==1){
System.out.println("恭喜获得三等奖,获得 3000 元");
}else if((n==5&&m==0)||(n==4&&m==1)){
System.out.println("恭喜获得四等奖,获得 200 元");
}else if((n==4&&m==0)||(n==3&&m==1)){
System.out.println("恭喜获得五等奖,获得 10 元");
}else if((n==0&&m==1)||(n==1&&m==1)||(n==2&&m==1)){
System.out.println("恭喜获得六等奖,获得 5 元");
}else{
System.out.println("没有中奖,感谢您对公益事业的贡献!");
}
}
public static boolean mun(int [] arr , int b) {
for (int i = 0; i < arr.length; i++) {
if(arr[i] == b){
return true;
}
}
return false;
}
}
java 双色球系统
最新推荐文章于 2024-08-19 16:01:20 发布