samedi 3 octobre 2020

Checking is the answer of a randomly created addition is correct in C#

:D

So I have just ran into a problem that I cannot check if the value, entered by a user is correct or not, in a randomly created addition.

I have already tried to change 'int' value into 'bool' but it did not work the way I wanted it to, I could not check the result with 'if' statement.

Here is my code:

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

namespace Fejszámolás_FB
{
    class Program
    {
        static void Main(string[] args)
        {
            Random rnd = new Random();
            int e;
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("");
                Console.WriteLine("Solve the following math problem!");
                Console.WriteLine(rnd.Next(50) + "+" + rnd.Next(50));
                    
                Console.Write("Your answer: ");
                    e = int.Parse(Console.ReadLine());
                
            }          

        Console.ReadKey();
        }
    }
} 

How should I get it working?




Aucun commentaire:

Enregistrer un commentaire