Help me fully explain this code please.

Joined
Jan 14, 2020
Messages
1
Reaction score
0
using System;
namespace ConsoleApp2
{
class Program
{
static void DispMenu()
{
Console.WriteLine("[1] Start\n[2] Instructions");
Console.Write("Enter your choice: ");
}
static void Main(string[] args)
{
Random numberGenerator = new Random();
int PCount = 0;
int QCount = 0;
int iScore = 0;
int iCount = 0;
int iChoice;

while (iCount == 0)
{
DispMenu();
iChoice = int.Parse(Console.ReadLine());

if (iChoice == 1)
{
Console.WriteLine("Press enter to start the game...");
Console.ReadLine();
iCount = 1;
}
else
{
Console.WriteLine("Just take your time and try to do it.");
}

}

while (QCount < 10)
{
int RandNum1 = numberGenerator.Next(1, 11);
int RandNum2 = numberGenerator.Next(1, 11);
Console.WriteLine("" + RandNum1 + " * " + RandNum2 + "");
Console.WriteLine();
int Input = Convert.ToInt32(Console.ReadLine());
int Answer = RandNum1 * RandNum2;

if (Input < 1 || Input > 100)
{
Console.WriteLine("The answer should be greater than 1 and less than 100.");
Console.ReadLine();
QCount--;
}
else
{

if (Input == Answer)
{
Console.WriteLine("Correct");
Console.WriteLine();
Console.WriteLine();
PCount++;
iScore++;
}
else
{
Console.WriteLine("The answer is " + Answer + ".");
Console.WriteLine();
Console.WriteLine();
}
}
QCount++;

}

Console.WriteLine("Finished. You scored " + iScore + "/10.");

}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

My Rock,Paper,Scissors Game 0
C# problem 1
help me with my code 1
Parking lot C# 5
How to try a range of hex values in C# code ? 0
Please, help me. 1
How do I get a decimal 1
Arduino Code Please Help 0

Members online

Forum statistics

Threads
474,056
Messages
2,570,439
Members
47,101
Latest member
DoloresHol

Latest Threads

Top