Why is RatioQuestion1 method not returning the desired result?

864G

New member
Joined
Oct 1, 2020
Messages
1
Programming Experience
Beginner
C#:
static void Main(string[] args)
{
    Console.WriteLine("Get ready for a *MATH SHOWDOWN*");
    Console.Write("If you would like a tutorial on how this works say \"1\", If you would like to go ahead and start say \"2\", And if you would like to see credits say '3'");

    int openingprompt = Convert.ToInt32(Console.ReadLine());

    if (openingprompt == 2)
    {
        FindProblem();
    }
    else if (openingprompt == 1)
    {
    } 

    Console.ReadLine();
}

static void RatioQuestion1()
{
    Console.Write("A math club has 25 members, of which 11 are boys and the rest are girls. What is the ratio of males to all club members");

    int ratioQ1 = Convert.ToInt32(Console.ReadLine());

    Console.WriteLine(ratioQ1);
    Console.ReadLine();
}

static void FindProblem()
{
    Console.Write("If you would like a ratio problem say '1'");

    int Problemtype = Convert.ToInt32(Console.ReadLine());

    if (Problemtype == 1)
    {
        FindRatioProblem();
    }
    else if (Problemtype == 2)
    {
    }
}

static void FindRatioProblem()
{
    Console.WriteLine("ratio question coming up!");

    Random rnd = new Random();
    int problemnum = rnd.Next(1);

    if (problemnum == 1)
    {
        RatioQuestion1();
    }
}
 
Last edited by a moderator:
Welcome to the forum.

Please use code tags when posting code on this forum and explain the problem you have with the code you are using in the body of the topic, not the title. The title of your topic has been changed to something relevant.
 
You need to explain what it is that you expect and what it is that happens. Also, I suspect that you have done no actual debugging, which you must before posting. That doesn't just mean running the project and treating it like a user would. It means using the debugger in VS, setting breakpoints, stepping through the code and examining the state as you go. At each step, you should have a clear understanding of what you expect to happen and you can see exactly what does happen so you can see exactly where and how reality differs from expectation. You can then see exactly why a particular method doesn't return the expected value. Even if you still can't fix the problem, at least you can tell us exactly where it occurs, what it is and what data was in use at the time it occurred. You need to do as much as you can first, then provide us with all the relevant information.
 
Back
Top Bottom