You probably have already figured this out by this time...
Console.Read() is reading what's typed in as a series of strings, and not as
a single integer.
Each individual character is being converted to integer.
"Mike Langworthy" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I am having a problem Breaking out of the while loop, it never terminates.
>any suggestions
>
> using System;
> using System.Collections.Generic;
> using System.Text;
>
> namespace ConsoleApplication1
> {
> class Program
> {
> static void Main(string[] args)
> {
> Random random = new Random();
> int returnValue = random.Next(1, 100);
> Console.WriteLine(returnValue);
>
> int Guess = 0;
> int i = 0;
>
> Console.WriteLine("Welcome to the Guessing game. Please Choose
> a Number between 1 and 100.");
>
> while(Guess != returnValue)
> {
> Guess = Convert.ToInt32(Console.Read());
>
> if (Guess <= returnValue - 75)
> {
> Console.WriteLine("You are so low you are in
> Hell.");
> }
> if (Guess <= returnValue - 50 )
> {
> Console.WriteLine("Put the Shovel down, you are too
> Low.");
> }
> if (Guess < returnValue )
> {
> Console.WriteLine("Woah buck, too low Try again");
> }
> if (Guess >= returnValue + 75 )
> {
> Console.WriteLine("Hey Flyboy, get your head out of
> the clouds");
> }
> if (Guess >= returnValue + 50 )
> {
> Console.WriteLine("Get off the damn roof you are
> too high");
> }
> }
> Console.WriteLine("Congratulations, you win ");
> Console.WriteLine("Press Enter to terminate...");
> Console.Read();
>
> }
>
>
>
>
> }
> }
>
|