using System;
namespace loopsandguessinggame
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("T H E G U E S S I N G G A M E");
Console.WriteLine("---------------------------------"); //title to game
int usernumber; //setting the user input variable
int counter; //settingthe counter for the loop
counter = 0; //the start counter value
Random rnd = new Random();
int randomnumber = rnd.Next(1, 1000); //creates a number between 1 and 1000
Console.WriteLine("Guess my number! It is between 1 and 1000."); //asking user to guess number
Console.WriteLine("You only have 25 tries, so guess wisely!"); //telling the user about number of tries
usernumber = Convert.ToInt32(Console.ReadLine()); //input of usernumber
for (int i = counter; i != 26 //setting loop to run 25 times
{
counter = counter + 1;
if (usernumber = randomnumber)
{
counter = 27;
Console.WriteLine("Well done you guessed correctly!");
Console.WriteLine("----------------------------------------");
Console.WriteLine("! ! Y O U B E A T T H E G A M E !!");
System.Environment.Exit();
}
else if (usernumber < randomnumber)
{
Console.WriteLine("Your number is too low guess again");
}
else
{
Console.WriteLine("Your number is too high guess again");
}
}
Console.WriteLine("You ran out of tries sorry!");
Console.WriteLine("-------------------------");
Console.WriteLine("! ! G A M E O V E R ! !");
}
}
}