c#开关问题。作业

c#开关问题。作业,c#,C#,这就是我目前所拥有的。我的问题是,当您输入正确或不正确的答案时,所有案例都没有响应。我真的不知道接下来该怎么办。程序要求您回答两个相乘的随机数。然后它会给你八个答案中的一个 int result = 0; int caseSwitch = 0; string question = DoMultiplication(out result); Console.WriteLine(question); int answe

这就是我目前所拥有的。我的问题是,当您输入正确或不正确的答案时,所有案例都没有响应。我真的不知道接下来该怎么办。程序要求您回答两个相乘的随机数。然后它会给你八个答案中的一个

        int result = 0;
        int caseSwitch = 0;

        string question = DoMultiplication(out result);
        Console.WriteLine(question);
        int answer = Convert.ToInt32(Console.ReadLine());

        if (answer == result)
        {
            switch (caseSwitch)
            {
                case 1:
                    Console.WriteLine("Very Good");
                    break;

                case 2:
                    Console.WriteLine("Excellent");
                    break;

                case 3:
                    Console.WriteLine("Nice Work");
                    break;

                case 4:
                    Console.WriteLine("Keep up the good work!");
                    break;

            }

        }
        else
        {
            switch (caseSwitch)
            {


                case 1:
                    Console.WriteLine("No, Please Try Again.");
                    break;

                case 2:
                    Console.WriteLine("Wrong, Try Once More");
                    break;

                case 3:
                    Console.WriteLine("Don't Give Up!");
                    break;

                case 4:
                    Console.WriteLine("No, Keep Trying!");
                    break;
CaseSwitch始终为=0。 您需要为其分配一个值,或者为开关添加一个默认大小写。

CaseSwitch始终为=0。 您需要为其分配一个值,或者为开关添加一个默认大小写。

CaseSwitch始终为=0。 您需要为其分配一个值,或者为开关添加一个默认大小写。

CaseSwitch始终为=0。
您需要为其分配一个值,或者为开关添加一个默认大小写。

您的
int caseSwitch=0并且我没有看到您在代码中将其更改为1-4中的任何一个。因此,如果您没有更改caseSwitch,您希望它做什么…

您的
int caseSwitch=0并且我没有看到您在代码中将其更改为1-4中的任何一个。因此,如果您没有更改caseSwitch,您希望它做什么…

您的
int caseSwitch=0并且我没有看到您在代码中将其更改为1-4中的任何一个。因此,如果您没有更改caseSwitch,您希望它做什么…

您的
int caseSwitch=0并且我没有看到您在代码中将其更改为1-4中的任何一个。所以,如果您没有更改caseSwitch,您希望它做什么…

caseSwitch始终为0,因此您的切换将始终失败,而不会向console写入任何内容

如果你想要一个随机响应,你可以这样做:

    int result = 0;
    int caseSwitch = new Random().Next(1, 4);

    string question = DoMultiplication(out result);
    Console.WriteLine(question);
    int answer = Convert.ToInt32(Console.ReadLine());

    if (answer == result)
    {
        switch (caseSwitch)
        {
            case 1:
                Console.WriteLine("Very Good");
                break;

            case 2:
                Console.WriteLine("Excellent");
                break;

            case 3:
                Console.WriteLine("Nice Work");
                break;

            case 4:
                Console.WriteLine("Keep up the good work!");
                break;

        }

    }
    else
    {
        switch (caseSwitch)
        {


            case 1:
                Console.WriteLine("No, Please Try Again.");
                break;

            case 2:
                Console.WriteLine("Wrong, Try Once More");
                break;

            case 3:
                Console.WriteLine("Don't Give Up!");
                break;

            case 4:
                Console.WriteLine("No, Keep Trying!");
                break;

caseSwitch始终为0,所以您的开关将始终失败,而不会向控制台写入任何内容

如果你想要一个随机响应,你可以这样做:

    int result = 0;
    int caseSwitch = new Random().Next(1, 4);

    string question = DoMultiplication(out result);
    Console.WriteLine(question);
    int answer = Convert.ToInt32(Console.ReadLine());

    if (answer == result)
    {
        switch (caseSwitch)
        {
            case 1:
                Console.WriteLine("Very Good");
                break;

            case 2:
                Console.WriteLine("Excellent");
                break;

            case 3:
                Console.WriteLine("Nice Work");
                break;

            case 4:
                Console.WriteLine("Keep up the good work!");
                break;

        }

    }
    else
    {
        switch (caseSwitch)
        {


            case 1:
                Console.WriteLine("No, Please Try Again.");
                break;

            case 2:
                Console.WriteLine("Wrong, Try Once More");
                break;

            case 3:
                Console.WriteLine("Don't Give Up!");
                break;

            case 4:
                Console.WriteLine("No, Keep Trying!");
                break;

caseSwitch始终为0,所以您的开关将始终失败,而不会向控制台写入任何内容

如果你想要一个随机响应,你可以这样做:

    int result = 0;
    int caseSwitch = new Random().Next(1, 4);

    string question = DoMultiplication(out result);
    Console.WriteLine(question);
    int answer = Convert.ToInt32(Console.ReadLine());

    if (answer == result)
    {
        switch (caseSwitch)
        {
            case 1:
                Console.WriteLine("Very Good");
                break;

            case 2:
                Console.WriteLine("Excellent");
                break;

            case 3:
                Console.WriteLine("Nice Work");
                break;

            case 4:
                Console.WriteLine("Keep up the good work!");
                break;

        }

    }
    else
    {
        switch (caseSwitch)
        {


            case 1:
                Console.WriteLine("No, Please Try Again.");
                break;

            case 2:
                Console.WriteLine("Wrong, Try Once More");
                break;

            case 3:
                Console.WriteLine("Don't Give Up!");
                break;

            case 4:
                Console.WriteLine("No, Keep Trying!");
                break;

caseSwitch始终为0,所以您的开关将始终失败,而不会向控制台写入任何内容

如果你想要一个随机响应,你可以这样做:

    int result = 0;
    int caseSwitch = new Random().Next(1, 4);

    string question = DoMultiplication(out result);
    Console.WriteLine(question);
    int answer = Convert.ToInt32(Console.ReadLine());

    if (answer == result)
    {
        switch (caseSwitch)
        {
            case 1:
                Console.WriteLine("Very Good");
                break;

            case 2:
                Console.WriteLine("Excellent");
                break;

            case 3:
                Console.WriteLine("Nice Work");
                break;

            case 4:
                Console.WriteLine("Keep up the good work!");
                break;

        }

    }
    else
    {
        switch (caseSwitch)
        {


            case 1:
                Console.WriteLine("No, Please Try Again.");
                break;

            case 2:
                Console.WriteLine("Wrong, Try Once More");
                break;

            case 3:
                Console.WriteLine("Don't Give Up!");
                break;

            case 4:
                Console.WriteLine("No, Keep Trying!");
                break;

caseSwitch始终为0 caseSwitch始终为0,因此您的切换将始终失败,而不向控制台写入任何内容我将在哪里查看如何从4种情况中选择?我知道将caseSwitch分配给1总是会给我这样的回答。如果你想随机选择caseSwitch总是0,请看我下面的答案caseSwitch总是0,所以你的切换总是会失败,而不向控制台写入任何内容。我在哪里可以看到如何从4个案例中选择?我知道将caseSwitch分配给1总是会给我这样的回答。如果你想随机选择caseSwitch总是0,请看我下面的答案caseSwitch总是0,所以你的切换总是会失败,而不向控制台写入任何内容。我在哪里可以看到如何从4个案例中选择?我知道将caseSwitch分配给1总是会给我这样的回答。如果你想随机选择caseSwitch总是0,请看我下面的答案caseSwitch总是0,所以你的切换总是会失败,而不向控制台写入任何内容。我在哪里可以看到如何从4个案例中选择?我知道将caseSwitch分配到1总是会给我这样的回答。如果你想随机选择,请看下面我的答案