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

  • Home
  • SEARCH
  • 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 8110211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:40:12+00:00 2026-06-06T01:40:12+00:00

I wrote this as a simple dice game. It works as I want except

  • 0

I wrote this as a simple dice game. It works as I want except it iterates 3 times with no answer on the first two iterations. The third time the question is asked and answered a output shows up.

No idea where in my code is the issue, I have gone over it over and over….lol any help =)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


/* I am very confused but for soem reason it only returns a value every 3 tries....I dont understand
 * I looked through the program and the only thing that occurs 3 times is the if else if else if statement 
 * but I dont see how that would do it....
 */
namespace Lab11
{
    class Program
    {
        static void Main(string[] args)
        {//declared constants
            const int NUM_1 = 1;
            const int NUM_6 = 6;

            Console.WriteLine("\t\t\tWelcome To a Game of Dice!");
            //Do while statement repeating the "roll again" question and performing the random numbers
            do
            {
                Again();

                Random ran = new Random();

                //if else if else if statement doing the random numbers and telling you rolled snake or box
                if (Again() == true)
                {
                    int num1 = ran.Next(1, 7);
                    int num2 = ran.Next(1, 7);
                    //if else statement determining the output for each roll in the console.
                    if (num1 == NUM_6 && num2 == NUM_6)
                    {
                        Console.WriteLine("\nYou Rolled BoxCars");
                    }
                    else if (num1 == NUM_1 && num2 == NUM_1)
                    {
                        Console.WriteLine("\nYou rolled Snake-Eyes");
                    }
                    else 
                    {
                        Console.WriteLine("\nYou Rolled...{0} and {1}", num1, num2);
                    }
                }
            } while (Again() == true);
            //Goodbye if you press 'n'
            Console.WriteLine("\n\nGoodBye");
            Console.ReadLine();

        }
        //the yes or no method asking if you want to play again
        //this is where I think the issue is but I dont see where or how....
        static bool Again()
        {
            char response;

            Console.Write("\n\nWould you like to roll the dice (y or n)? ");
            response = char.Parse(Console.ReadLine());
            response = char.ToLower(response);

            if (response == 'y')
                return true;
            else
                return false;
        }          

    }
}
  • 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-06T01:40:13+00:00Added an answer on June 6, 2026 at 1:40 am
    Again();
    
    Random ran = new Random();
    
    if (Again() == true)
    {
        // ...
    

    Here, you are calling Again() twice, which causes it to prompt the user twice. You could change it like this:

    bool rollAgain = Again();
    
    Random ran = new Random();
    
    if (rollAgain == true)
    {
        // ...
    

    You have a similar issue here:

    } while (Again() == true);
    

    To solve everything, you could probably introduce the rollAgain variable outside the do-while statement and assign it inside.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I recently wrote this fairly simple game of life in JavaScript. Within this
I wrote a simple game and I want to add custom pointer. I created
I wrote this simple Munin plugin to graph average fan speed and I want
I wrote this simple javascript code: $(input[type='file']).attr(value, ); It works in Firefox and Chrome
I wrote this simple C code and compiled it using Visual Studio 2010, with
So I wrote this simple console app to aid in my question asking. What
I've wrote this simple piece of code. And I have a slight problem with
I'm trying to retrieve folders name from a zip file. I wrote this simple
I want to load this simple something into my Editor: Write:-repeat,write(hi),nl,fail. So that it
I wrote this simple C program: int main() { int i; int count =

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.