Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

For anyone struggling to do the homework for "How to Program in C# - Loops (E04)", here's my code:

NiceSlice66NiceSlice66 Member
edited August 29 in Brackeys' Tutorials

using System;


namespace Programming_Lesson_4

{

    class Program

    {

        static void Main(string[] args)

        {

            Random numberGen = new Random(); 

         


            int roll = 0;

            int roll2 = 1;

            int attempts = 0;


            Console.WriteLine("Press enter to roll the dice:");


            while(roll != roll2) 

            {

                Console.ReadKey();


                roll = numberGen.Next(1, 7);

                roll2 = numberGen.Next(1,7);


                Console.WriteLine("\nRoll 1: " + roll);

                Console.WriteLine("Roll 2: " + roll2);

                attempts++;

            }


            Console.WriteLine("It took you " + attempts + " attempts to roll twin numbers!");


            Console.ReadKey();

        }

    }

}

Sign In or Register to comment.