using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lab4
{
class
GuessTheNumberGame
{
static void
Main(string[] args)
{
while (true)
{
int randomNum = GenerateNum(0, 1000);
int counter = 1;
while (true)
{
Console.WriteLine("Input
a number between 0 to 1000 or -1 to exit:");
int num =
Convert.ToInt32(Console.ReadLine());
if (num > randomNum)
{
Console.WriteLine("Too high. Please
try again!");
++counter;
continue;
}
else if
(num < randomNum)
{
Console.WriteLine("Too low. Please
try again!");
++counter;
continue;
}
else if
(num == -1)
{
return;
}
else
{
Console.WriteLine("Congratulations!You
guessed the number!");
}
}
}
}
static int
GenerateNum(int min,
int max)
{
Random random =
new Random();
return random.Next(min, max);
}
}
}