Answers for "dice roll with attempts script"

C#
0

dice roll with attempts script

Random rnd = new Random();
    int attempts = 0;
    int i;

    while(true)
    {
        attempts++;
        i = rnd.Next(0, 7);
        Console.WriteLine("You rolled a " + i);
        Console.ReadKey();

        if(i == 6)
        {
            Console.WriteLine("It took you " + attempts + " times to roll a six");
            break;
        }
    }
Posted by: Guest on September-30-2021

C# Answers by Framework

Browse Popular Code Answers by Language