Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:02:29+00:00 2026-06-13T16:02:29+00:00

I have two issues that I’m not sure how to fix. diceThrow() is supposed

  • 0

I have two issues that I’m not sure how to fix.

diceThrow() is supposed to randomly roll a die and come up with an answer 1-6 multiple times, but only comes up with one 1-6 answer and only does that. i.e. (6, 6, 6, 6, 6, 6, etc)

and for rollDice(), I’m not sure if I just poorly defined “i” or maxRolls, but it should be that when i > maxRolls, the program should end and reset.

Any advice on how to fix either of these is greatly appreciated, thanks!

//somewhere else in code
    int maxRolls = RollsNumber();
    int throwresult = diceThrow();
    int i;
//*******************************

    private void rollButton_Click(object sender, EventArgs e)
    {
        rollDice();
        wagerTextBox.Text = null;
        wagerTextBox.Text = scoreTextBox.Text;
        diceThrow();

        MessageBox.Show(Convert.ToString(throwresult));

        if (maxRolls < i)
        {
            MessageBox.Show("You got too greedy.");

           //reset the form

        }
    }
    // Decides the maximum number of rolls before the player loses
    static public int RollsNumber()
     {
        Random rolls = new Random();
        return rolls.Next(1, 10);

    }
    // Throws the dice
    static public int diceThrow()
    {
        Random dice = new Random();
       return dice.Next(1, 7);
    }
    private void rollDice()
    {
        for (i = 0; i <= maxRolls; i++)
        {

                int wager = Convert.ToInt32(wagerTextBox.Text);


                int score = wager * 100;


                scoreTextBox.Text = Convert.ToString(score);



        }  
    }

}
}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:02:30+00:00Added an answer on June 13, 2026 at 4:02 pm

    You are using same seed with the Random.

    As msdn states in Random class

    The random number generation starts from a seed value. If the same seed is used repeatedly, the same series of numbers is generated. One way to produce different sequences is to make the seed value time-dependent, thereby producing a different series with each new instance of Random.

    A simple way in your case is to not create new Random each time.

     // Throws the dice
    static Random diceRandom = new Random();
    static public int diceThrow()
    {
       return diceRandom .Next(1, 7);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having two issues that I have not been able to figure out.
Hi I'm new to JQuery. I have an two issues that I can't figure
Have two issues one is showFromToolbar statement format warning issue and another is that
i have two issues with that: 1) i have phone format something like this:
My issue is that I have two (or more) divs of the same class,
I have two issues in this google chart. I want to either get rid
I need to override styles for two EditText instances. I have two issues regarding
I have found many people with simliar issues but no soultions...basically I have two
I have following fiddle: http://jsfiddle.net/BFSH4/ As you see there are two issues: The h1
I have two issues. 1.When I use decimals to convert, it always comes out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.