i want the answer on c Enter Winning Number Enter Number of

i want the answer on c#
Enter Winning Number
Enter Number of Numbers Purchased
For each purchase:
    Enter the number into array
For each number in array:
    For each value of number:
        Compare to winning #
            If match
                (6th) || ((1-5)+6th) = $4** if (PowerBallMatch(arr1,arr2) || (NumberMatch(arr1,ar2) == 1 && PowerBallMatch(arr1,arr2))               
                ((2x(1-5))+6th) || (3x(1-5)) = $7 ** if ( (NumberMatch(arr1,arr2)==3) || PowerBallMatch(arr1,arr2) && NumberMatch(arr1,arr2) == 2))                
                ((3x(1-5))+6th) || (4x(1-5)) = $100
                ((4x(1-5))+6th) = $50,000
                (5x(1-5)) = $1,000,000
                All match = Grand Prize
                Increase prize
Display results

Solution

using System.IO;
using System;

class Program
{
    static void Main()
    {
        // Configure the grand prize amount
        double GrandPrize = 90000000000;
      
        Console.Write(\"Enter winning number (comma seperated values) : \");
        string commaSeperatedValues = Console.ReadLine();
        int[] winningNumbers = convertToArr(commaSeperatedValues);
      
        int noOfPurchases = 0;
        Console.Write(\"Enter number of purchases : \");
        int.TryParse(Console.ReadLine(), out noOfPurchases);
      
      
        int[][] purchaseList = new int[noOfPurchases][];
      
        for (int i=0; i<noOfPurchases; i++) {
            Console.Write(\"Enter the number (comma seperated values) : \");
            commaSeperatedValues = Console.ReadLine();
            purchaseList[i] = convertToArr(commaSeperatedValues);          
        }
      
        for (int i=0; i<noOfPurchases; i++) {
            int[] currentNumber = purchaseList[i];
            double totalPrize = 0;
          
            if (PowerBallMatch(currentNumber, winningNumbers) || (PowerBallMatch(currentNumber, winningNumbers) && NumberMatch(currentNumber, winningNumbers)==1)) {
                totalPrize = 4;                              
            }
          
            if (NumberMatch(currentNumber, winningNumbers)==3 || (PowerBallMatch(currentNumber, winningNumbers) && NumberMatch(currentNumber, winningNumbers)==2)) {
                totalPrize = 7;                              
            }
          
            if (NumberMatch(currentNumber, winningNumbers)==4 || (PowerBallMatch(currentNumber, winningNumbers) && NumberMatch(currentNumber, winningNumbers)==3)) {
                totalPrize = 100;                              
            }
          
            if (PowerBallMatch(currentNumber, winningNumbers) && NumberMatch(currentNumber, winningNumbers)==4) {
                totalPrize = 50000;                              
            }
          
            if (NumberMatch(currentNumber, winningNumbers)==5) {
                totalPrize = 1000000;
            }
          
            if (NumberMatch(currentNumber, winningNumbers)==5 && PowerBallMatch(currentNumber, winningNumbers)) {
                totalPrize = GrandPrize;
            }

            printTicket(currentNumber);
            Console.WriteLine(\" Price = \"+totalPrize);
        }      
    }
  
    static int[] convertToArr(string commaSeperatedValues) {
        string[] splittedValues = commaSeperatedValues.Split(\',\');
        int[] arr = new int[6];
        for (int i=0; i<6; i++) {
           int.TryParse(splittedValues[i].Trim(), out arr[i]);
        }
        return arr;
    }
  
    static bool PowerBallMatch(int[] arr1, int[] arr2) {
        if (arr1[5] == arr2[5]) {
            return true;
        }
        return false;
    }
  
    static int NumberMatch(int[] arr1, int[] arr2) {
        int count = 0;
        for (int i=0; i<5; i++) {
            for (int j=0; j<5; j++) {
                if (arr1[i] == arr2[j]) {
                    count++;
                    break;
                }
            }
        }
        return count;
    }
  
    static void printTicket(int[] arr) {
        Console.Write(\"[\");
        for (int j=0; j<5; j++) {
            Console.Write(arr[j] + \", \");          
        }
        Console.Write(arr[5]+\"]\");
    }
}

i want the answer on c# Enter Winning Number Enter Number of Numbers Purchased For each purchase: Enter the number into array For each number in array: For each
i want the answer on c# Enter Winning Number Enter Number of Numbers Purchased For each purchase: Enter the number into array For each number in array: For each
i want the answer on c# Enter Winning Number Enter Number of Numbers Purchased For each purchase: Enter the number into array For each number in array: For each

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site