#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# How do i create this program only using C#?

daytona beachMember Posts: 1
edited October 2016 in C#

Children Math Game
Instructions

Randomize 2 number. Randomize a number between 1 and 3. 1 equal addition, 2 equals subtraction, 3 for multiplication

show the two plus the operation for the student to answer. Have the student input his answer. check and count the correct answers. Give 10 tries.

Tagged:

• Member Posts: 115 ✭✭✭

By writing the code.

• IndiaMember Posts: 21
• AthensMember Posts: 2

Here is a small solution about your request. I made it as simple as possible, so you can edit it.

``````static void Main(string[] args)
{
int x = 1;
int y = 1;
int oper = 1;
string operation = "";
int computerAnswer = 0;
int answer = 0;
int correct = 0;
int wrong = 0;

Random rands = new Random();

for (int i = 1; i <= 10; i++)
{
oper = rands.Next(1, 4);

switch (oper)
{
case 1:
operation = "+";
x = rands.Next(1, 100);
y = rands.Next(1, 100);
computerAnswer = x + y;
break;
case 2:
operation = "-";
x = rands.Next(1, 100);
y = rands.Next(1, 100);
computerAnswer = x - y;
break;
case 3:
operation = "*";
x = rands.Next(1, 10);
y = rands.Next(1, 10);
computerAnswer = x * y;
break;
default:
break;
}
Console.Write("Try {3}:\t{0} {1} {2} = ", x, operation, y, i);
try
{
}
catch (Exception)
{

Console.WriteLine("That was not a number!");
}

{
Console.WriteLine("Correct!");
correct++;
}
else
{
Console.WriteLine("Wrong...");
wrong++;
}
}
Console.WriteLine("\n--------------------------------------------------\n");
Console.WriteLine("You made {0} correct answers and {1} wrong", correct, wrong);
switch (correct)
{
case 10:
Console.WriteLine("You are excellent!!!!");
break;
case 9:
case 8:
case 7:
Console.WriteLine("You are very good!");
break;
case 6:
case 5:
case 4:
Console.WriteLine("You are good, let's try a little more");
break;
default:
Console.WriteLine("You need more practice");
break;
}