Howdy, Stranger!

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

BRACKEYS - Solution to C# Tutorial 04 Challenge

BrackeysBrackeys Administrator
edited June 26 in Announcements

Hey everyone!

Here is my solution to the challenge from the C# Tutorial 04 (Loops) video that is out soon.

Have fun with it! 😀

using System;

namespace My_Awesome_Program
{
  class Program
  {
    static void Main(string[] args)
    {
      Random numberGen = new Random();

      int roll01 = 0;
      int roll02 = 1;
      int attempts = 0;

      Console.WriteLine("Press enter to roll the dice.");
       
      while(roll01 != roll02)
      {
        Console.ReadKey();
         
        roll01 = numberGen.Next(1, 7);
        roll02 = numberGen.Next(1, 7);
         
        Console.WriteLine("Roll 1: " + roll01);
        Console.WriteLine("Roll 2: " + roll02 + "\n");

        attempts++;
      }

      Console.WriteLine("It took you " + attempts + " attempts to roll two of a kind.");

      // Wait before closing
      Console.ReadKey();
    }
  }
}
Sign In or Register to comment.