using System;
namespace randDice
{
class randDice
{
static void Main(string[] args)
{
int diceNmbr, guess, cont;
string input, guessStr;
Random dice = new Random();
Console.WriteLine("Welcome to the guee the dice number game.");
Console.WriteLine("Guess between number 1 to 6.");
do
{
diceNmbr = (int)(dice.NextDouble() * 6) + 1;
Console.WriteLine("Dice number : {0}",diceNmbr);
do
{
input = Console.ReadLine();
guess = Int32.Parse(input);
if ((guess < 1) || (guess > 6))
Console.WriteLine("Choose between the number 1 to 6 only.");
}while((guess>=1)||guess<=6);
if (guess > diceNmbr)
Console.WriteLine("Too big. Try again.");
else if (guess < diceNmbr)
Console.WriteLine("Too small. Try again.");
else
Console.WriteLine("Great guess!!");
Console.WriteLine("Do you wish to continue? Press 1 to continue or 0 to quit.");
guessStr = Console.ReadLine();
cont = Int32.Parse(guessStr);
}while(cont==1);
}
}
}
I get it right till the checking part (line 17-23). My problem is after that. No matter what the condition is, the program will not tell whether the guessed number is too big or too small or whether is it correct. Can someone tell me what went wrong?
Any help is greatly appreciated.
edit : never mind. I already figured out what went wrong. the 2nd do-while should be while((guess < 1)||guess > 6), not while((guess>=1)||guess<=6). Sorry for bothering you guys.
This post has been edited by red_4900: 29 September 2008 - 09:23 AM

New Topic/Question
Reply




MultiQuote




|