java- color ball

com.find.shuzu Package; 

Import java.util.Random; 
Import java.util.Scanner; 

public class ShuangSeQiu2 { 
    public static void main (String [] args) { 
        int COUNT = 0; // note how much to buy 
        int arr [ ] = new int [7]; // store lottery 

        boolean flag = false; // switch, 

        the while (to true) { 
            // print menu 

            System.out.println ( "************* *** Welcome to the color ball system *************** "); 
            System.out.println (" 1 to buy lottery tickets. "); 
            . System.out.println (" 2 View lottery "); 
            System.out.println (" 3 exit ");. 

            // select 
            Scanner Scanner = new new Scanner (System.in);  
            System.out.println (" select the features you want to perform ");
            int = scanner.nextInt choice (); 
            Switch (Choice) { 
                Case 1: 
                    System.out.println ( "=" to enter the lottery ..... "); 
                    System.out.println (" Please enter you need to buy Note number "); 
                    COUNT = scanner.nextInt (); 
                    //. 6 red, a blue 
                    for (int I =. 1; I <=. 7; I ++) { 
                        ! IF (I =. 7) { 
                            the System.out. the println ( "first input" + i + "red ball"); 
                        } the else { 
                            System.out.println ( "enter a basketball"); 
                        } 
                        // array stored 
                        int sc = scanner.nextInt ();
                        arr [i - 1] = sc;
                    } 

                    // output ball number you purchased 
                    System.out.println ( "You bought a total of" + count + "Note" + "spent" + count * 2 + "Yuan"); 
                    for (int NUM: arr) { 
                        of System.out.print (NUM + "\ T"); 
                    } 
                    System.out.println (); 
                    In Flag to true =; 
                    BREAK; 
                Case 2: 
                    IF (In Flag) { 
                        System.out.println ( "=" Show ... .. See jackpot "); 
                        // winning numbers: 
                        luckNum getLuckNum = int [] (); 

                        // test results for winning
                        int // [] = {1,2,3,4,5,6,7} luckNum; 
                        // ball and their alignment determines the award winning numbers: 
                        int = getCompareResult Level (ARR, luckNum); 
                        Switch (Level ) { 
                            Case 1: 
                                System.out.println ( "first prize" + 500 * count + "ten thousand yuan"); 
                                BREAK; 
                            Case 2: 
                                System.out.println ( "second prize" + 400 * count + "Wan yuan "); 
                                BREAK; 
                            Case. 3: 
                                System.out.println (" four prize "+ 100 * count + "dollars"); 
                                System.out.println (" third place "+ 300 * count +" dollars ");
                                break;
                            4 Case: 
                                BREAK; 
                            Case 5: 
                                System.out.println ( "fifth prize" + 50 * count + "ten thousand yuan"); 
                                BREAK; 
                            Case 6: 
                                System.out.println ( "Liu Dengjiang" + 5 * count + "million"); 
                                BREAK; 
                            Case 7: 
                                System.out.println ( "did not win, do not lose heart, make persistent efforts"); 
                                BREAK; 
                        } 

                    } the else { 
                        System.out.println ( "you do not buy lottery tickets, please to buy ");
                    }

                    break;
                . 3 Case: 
                    System.out.println ( "=" exit the system to exit the system ..... "); 
                    return; 
            } 
        } 
    } 

    Private getCompareResult static int (int [] ARR, int [] luckNum) { 
        // prize level 
        int = 0 Level; 
        // red ball 
        int redEquli = 0; 
        // basketball 
        int blueEqyli = 0; 

        for (int I = 0; I <=. 6; I ++) { 
            IF (I =. 6!) { 
                for (int = 0 J ; J <=. 5; J ++) { 
                    IF (ARR [I] == luckNum [J]) { 
                        redEquli ++; 
                    } 
                } 
            } the else {
                if (arr[i] == luckNum[6]) {
                    blueEqyli++;
                }
            }
        }

        //判断个数
        if (redEquli == 6 && blueEqyli == 1) {
            level = 1;
        } else if (redEquli == 6) {
            level = 2;
        } else if (redEquli == 5&&blueEqyli==1) {
            level = 3;
        } else if (redEquli == 5 || (redEquli == 4 && blueEqyli == 1)) {
            level = 4;
        } else if (redEquli == 4 || (redEquli == 3 && blueEqyli == 1)) {
            level = 5;
        } else if (redEquli == 1) {
            level = 6;
        The else {}
            =. 7 Level; 
        } 
        return Level; 
    } 

    Private static int [] getLuckNum () { 
        // definition array, storing the winning number 
        int ARRS [] = new new int [. 7]; 
        the Random Random new new = the Random (); 
        for (int I = 0; I <=. 6; I ++) { 
            IF (I =. 6) {! 
                // red ball 
                ARRS [I] = random.nextInt (34 is); 
            } the else { 
                // basketball 
                arrs [i] = random.nextInt (17 ); 
            } 
        } 
        for (int A: ARRS) { 
            of System.out.print (A + "\ T"); 
        } 
        System.out.println (); 
        return ARRS;
    }
}

  Code----------------------------------

Guess you like

Origin www.cnblogs.com/zimo-bwl1029-s/p/11228424.html