title: Guess the number C# game
body: <p>I need to write a 'guess the number' program including numbers between 1-100 including a While Loop. It also needs to tell the user how many guesses they've had at the end and I frankly have no idea how to do that. Also, the user has to type their guess 3 times before the program responds and tells them whether it's higher or lower than the random number.
  Here's my code:</p>
  
  <pre><code>Random RandomClass = new Random();
  int x = RandomClass.Next(1, 100);
  Console.WriteLine("I am thinking of a number between 1-100. Can you guess what it is?");
  int guess = 0;
  while (guess != x)
  {
    guess = Convert.ToInt32(Console.ReadLine()); // ReadLine 1
    if (guess == x)
    {
      Console.WriteLine("Well done! The answer was " + x + " and you found it in XXXX guesses");
      Console.ReadLine(); // ReadLine 2
    }
    else if (guess != x)
    {
      if (guess &lt; x)
      {
        Console.WriteLine("No, the number I am thinking of is higher than " + guess + ". Can you guess what it is?");
        Console.ReadLine(); // ReadLine 3
      }
      else if (guess &gt; x)
      {
        Console.WriteLine("No, the number I am thinking of is lower than " + guess + ". Can you guess what it is?");
        Console.ReadLine(); // ReadLine 4
      }
    }
    Console.ReadLine(); // ReadLine 5.
  }
  </code></pre>
  
  <p>And here's what it looks like when I debug:</p>
  
  <pre><code>I am thinking of a number between 1-100. Can you guess what it is?
  50
  50
  50
  No, the number I am thinking of is lower than 50. Can you guess what it is? 
  40
  40
  40
  No, the number I am thinking of is higher than 40. Can you guess what it is?
  45
  45
  45
  </code></pre>
  
  <p>and so on.</p>