Howdy, Stranger!

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

how do i make this 2 of a kind from youtube challenge of brackeys

This is what I did but it is stopping when one of the numbers roll 6

this is from https://www.youtube.com/watch?v=9ozOSKCiO0I&list=PLPV2KyIb3jR4CtEelGPsmPzlvP7ISPYzR&index=5

of brackeys

Here is the code ⤵️

PLEASE HELP ME

using System;


namespace my_programmC

{

    class Program

    {

        static void Main(string[] args)

        {    

            Random numberGen = new Random();


            int roll = 0;

            int rolL1 = 0;

            int attempts = 0;


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

            

            

            while(roll != 6 && rolL1 != 6) {

                Console.ReadKey();

                

                roll = numberGen.Next(1, 7);

                rolL1 = numberGen.Next(1, 7);

                Console.WriteLine("You rolled " + roll + " and " + rolL1);

                attempts++;

            }


            Console.WriteLine("It took you " + attempts + " attempts to roll a six.");




            // this is for not to close before clicking

            Console.ReadKey();

        }

    }

}

Can somebody help, please

Answers

  • Praesh_05Praesh_05 Member
    edited March 2021

    I modified it a little. It won't give you correct answers every time but sometimes it gives correct answer and this problem solved "This is what I did but it is stopping when one of the numbers roll 6."

    My code:

    using System;


    namespace vurtual_life

    {

        class Program

        {

            static void Main(string[] args)

            {

                Console.Title = "Skynet";

                Console.ForegroundColor = ConsoleColor.DarkBlue;

                Console.WindowHeight = 30;


                Random numberGen = new  Random();


                int roll01 = 0;

                int roll02 = 0;

                int attempts = 0;


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


                while (roll01 != 3 && roll02 != 3) {

                    Console.ReadKey();


                    roll01 = numberGen.Next(1, 4);

                    roll02 = numberGen.Next(1, 4);

                    Console.WriteLine("You rolled in dice 01 is: " + roll01 + " and in dice 02 is: " + roll02);


                    attempts++;


                }



                Console.WriteLine("It took  you " + attempts + " attempts to roll six.");

                

                    

                


                Console.ReadKey();

            }

        }

    }

    Hope it helps 😀

Sign In or Register to comment.