Hi...How can I validate user input when the user's input is greater than 10.
I mean, in this code below if the user introduce a value greater than 10, I want to print a message on screen. What operator or comparision should I use and where?..Here is the code:
********************************************************
private static void GusssingGame()
{
Console.Clear();
Console.WriteLine(" ***** GUESS THE NUMBER GAME ******");
Random myRandom = new Random();
int randomNumber = myRandom.Next(1, 11);
int intentos = 0;
bool incorrect = true;
do
{
Console.Write("Choose a number between 1 and 10 and press ENTER: ");
string result = Console.ReadLine();
intentos++;
if (result == randomNumber.ToString())
{
incorrect = false;
}
else
{
Console.WriteLine("Incorrect. Try again!");
}
} while (incorrect == true);
*************************************************************
Bryian TanRank #396 · 6.3K reputationPosted Jan 13, 2017, 7:57 AM EST
Guest User60 reputationPosted Jan 13, 2017, 9:15 AM EST
Bryian TanRank #396 · 6.3K reputationPosted Jan 13, 2017, 9:53 AM EST