用Java实现双色球彩票系统

import java.util.Scanner;
public class Lianxi2 {
    public static void main(String[] args) {
        String S="";
        int n=0;
        int m=0;
        System.out.println("---------------------");
        System.out.println("|欢迎进入双色球彩票系统!|");
        System.out.println("---------------------");
        System.out.println("温馨提示:请按提示语进行操作哦!");
        for(int i=1;i<=6;i++)
        {
            System.out.println("请输入您的红球号码"+i+":");
            Scanner sc1 = new Scanner(System.in);
            int x= sc1.nextInt();
            if(x>=1&&x<=39)
            {
                S+=x;
                S+=",";
            }
            else
            {
                System.out.println("你输入号码有误,请重新输入!");
                i--;
            }
        }
        for(int j=1;j<=1;j++)
        {
            System.out.println("请输入你的蓝球号码"+j+":");
            Scanner sc2 = new Scanner(System.in);
            int y =sc2.nextInt();
            if(y>=1&&y<=16)
            {
                S+=y;
            }
            else
            {
                System.out.println("你输入号码有误,请重新输入!");
                j--;
            }
        }
        System.out.println("你的彩票号码是"+S);
        String S1="33,21,10,8,13,27,1";
        System.out.println("本次大奖号码是"+S1);
        String[]strs=S.split(",");
        for(int i=0;i<strs.length;i++) {
            switch (strs[i])
            {
                case "33":{
                    n++;
                    break;
                }
                case "21": {
                    n++;
                    break;
                }
                case "10":{
                    n++;
                    break;
                }
                case "8": {
                    n++;
                    break;
                }
                case "13": {
                    n++;
                    break;
                }
                case "27": {
                    n++;
                    break;
                }
                }
            }
        switch (strs[6]) {
            case "1": {
                m++;
                n++;
                break;
            }
            default:
                break;
        }
            switch (n)
            {
                case 0:{
                    System.out.println("很遗憾,你未中奖!");
                    break;
                }
                case 1:{
                    if(m==1){
                        System.out.println("恭喜你,中了六等奖!");
                    }
                    else
                    {
                        System.out.println("很遗憾,你未中奖!");
                    }
                    break;
                }
                case 2:{
                    if(m==1)
                    {
                        System.out.println("恭喜你,中了六等奖!");
                    }
                    else
                    {
                        System.out.println("很遗憾,你未中奖!");
                    }
                    break;
                }
                case 3: {
                    if (m == 1)
                    {
                        System.out.println("恭喜你,中了六等奖!");
                    }
                    else
                    {
                        System.out.println("很遗憾未中奖!");
                    }
                    break;
                }
                case 4:{
                    System.out.println("恭喜你,中了五等奖!");
                    break;
                }
                case 5:{
                    System.out.println("恭喜你,中了四等奖!");
                    break;
            }
                case 6:{
                    if(m==1)
                    {
                        System.out.println("恭喜你,中了三等奖!");
                    }
                    else
                    {
                        System.out.println("恭喜你,中了二等奖!");
                    }
                    break;
                }
                case 7:{
                    System.out.println("恭喜你,中了一等奖!");
                    break;
                }
        }
    }
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值