M
Mike Langworthy
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();
}
}
}
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();
}
}
}