java program for powerball lottery
<p>I have to check all test cases which i have given in arrays but i am not getting perfect answer.Please help me with this question.Create a <code>PowerBall</code> class that contains:</p>

<ul>
<li>A field for an <code>int</code> array of size 6. </li>
<li>A constructor that initializes this array with 6 random values (0-9). </li>
<li>A method called <code>checkMatch</code> that takes as an argument an <code>int</code> array and returns how many numbers match the class's <code>int</code> array. To match, the same numbers must be in the same position.</li>
</ul>

<p>Write a main class which asks to user to enter 6 numbers as their lottery ticket and store it in an array. Then create a <code>PowerBall</code> object and give the user's ticket to the <code>checkMatch</code> method. Then figure out the amount won based on the return value.</p>

<p>The winnings are determined as follows:</p>

<ul>
<li>If 0 numbers match, no winnings</li>
<li>If 1 number matches, win $4</li>
<li>If 2 numbers match, win $7</li>
<li>If 3 numbers match, win $100</li>
<li>If 4 numbers match, win $10,000</li>
<li>If 5 numbers match, win $1 Million</li>
<li>If all 6 numbers match, win Grand Prize of $450 Million</li>
</ul>

<p>Output the user's lottery ticket, the powerball numbers, how many matched, and the amount of money won.</p>

<pre><code>class PowerBall {

    /*
     * ALL PRIVATE DATA BELOW
     */

    private int[] winningNumber;
    private int[] ticketNumber;
    private long cash;
    static private IntUtil u = new IntUtil();
    int matchBalCount ;
    int powerBallMatchCount;

    public int cash() {

        for (int i = 0; i &lt; winningNumber.length; i++) {
            for (int j = 0; j &lt; ticketNumber.length; j++) {
                if (i == winningNumber.length-1 &amp;&amp; ticketNumber[i] == winningNumber[j]) {
                    powerBallMatchCount=1;
                } else if (ticketNumber[i] == winningNumber[j]) {
                    matchBalCount++;
                }
            }

            }
        return 100;
    }


    public void check(int matchBalCount,int powerBalCount){

        System.out.println("prize---matchBalCount::"+matchBalCount+" ,powerBallMatchCount::"+powerBallMatchCount);
        if (matchBalCount == 0 &amp;&amp; powerBallMatchCount&gt;0) {
            System.out.println("4");
        }else if (matchBalCount == 1 &amp;&amp; powerBallMatchCount&gt;0) {
            System.out.println("4");
        }else if (matchBalCount == 2 &amp;&amp; powerBallMatchCount&gt;0) {
            System.out.println("7");
        }else if (matchBalCount == 3 &amp;&amp; powerBallMatchCount&lt;0) {
            System.out.println("7");
        }else if (matchBalCount == 3&amp;&amp; powerBallMatchCount&gt;0) {
            System.out.println("100");
        }else if (matchBalCount == 4 &amp;&amp; powerBallMatchCount&lt;0) {
            System.out.println("100");
        }else if (matchBalCount == 4 &amp;&amp; powerBallMatchCount&gt;0) {
            System.out.println("50000");
        }else if (matchBalCount == 5 &amp;&amp; powerBallMatchCount&gt;0) {
            System.out.println("1lakh");
        } 


    }


    PowerBall(int[] w, int[] t) {
        winningNumber = w;
        ticketNumber = t;
        cash = 0;
     check(matchBalCount,powerBallMatchCount);
    }

    private static void test1() {
        int[] w = {4, 8, 19, 27, 24, 10};
        {
            int[] n = {4, 8, 19, 27, 24, 10};
            PowerBall x = new PowerBall(w, n);
           // x.cash();
        }
        {
            int[] n = {24, 27, 19, 8, 4, 10};
            PowerBall x = new PowerBall(w, n);
        }
        {
            int[] n = {24, 27, 19, 8, 4, 5};
            PowerBall x = new PowerBall(w, n);
        }
        {
            int[] n = {124, 127, 119, 18, 14, 10};
            PowerBall x = new PowerBall(w, n);
        }
        {
            int[] n = {124, 127, 119, 18, 14, 5};
            PowerBall x = new PowerBall(w, n);
        }
        {
            int[] n = {124, 127, 119, 18, 14};
            PowerBall x = new PowerBall(w, n);
        }
        {
            int[] n = {124, 124, 19, 119, 18, 14};
            PowerBall x = new PowerBall(w, n);
        }
    }

    private static void testRandom() {
        int[] w = {4, 8, 19, 27, 24, 10};
        int max = 10;
        long c = 0;
        for (int i = 0; i &lt; max; ++i) {
            int[] n = u.generateRandomNumber(6, true, 1, 99);
            PowerBall x = new PowerBall(w, n);
            c = c + x.cash();
        }
        System.out.println("Out of " + max + " times you win " + c + "$");
    }

    private static void testBench() {
        test1();
        testRandom();
    }

    public static void main(String[] args) {
        System.out.println("PowerBall.java");
        testBench();
        System.out.println("Done");
    }

}
</code></pre>