$65 roulette wheel in csharp

Here is some sample code to create a $65 roulette wheel in C#:

main.cs
using System;

namespace Roulette
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create an array to hold the numbers on the wheel
            int[] numbers = new int[38];
            for (int i = 0; i < 37; i++)
            {
                numbers[i] = i + 1;
            }
            numbers[37] = 0;

            // Set up the odds for each number
            double[] odds = new double[38];
            odds[0] = 35;
            for (int i = 1; i < 37; i++)
            {
                odds[i] = 1;
            }
            odds[37] = 35;

            // Create a random number generator
            Random rand = new Random();

            // Spin the wheel
            int number = numbers[rand.Next(0, 38)];
            Console.WriteLine("The ball landed on " + number + ".");

            // Pay out according to the odds
            double payout = odds[number] * 65;
            Console.WriteLine("You win $" + payout + ".");
        }
    }
}
1003 chars
39 lines

This code sets up an array to hold the numbers on the wheel, and an array to hold the odds for each number. It then creates a Random object to simulate spinning the wheel, and selects a random number from the array. Finally, it calculates the payout using the odds for the selected number and multiplies it by $65 for the cost of the game.

gistlibby LogSnag