Happy New Year guys, I hope you enjoying your holidays.
So thats my problem
Write a console-based program that generates a random
number between 1 and 10. (In other words, min is 1 and max
is 11.) Ask a user to guess the random number, then display
the random number and a message indicating whether the
user's guess was too high, too low, or correct.
My question is how can I just keep asking the user the number over and over? Cause I have to run the application everyime ctrl + f5, and its annoying.
Thats my solution
double userNumber;
string stringUserNumber;
Random randomNumberGenerator = new Random();
int randomNumber;
randomNumber = randomNumberGenerator.Next(1, 11);
Console.WriteLine("Please enter your number from 1 to 10");
stringUserNumber = Console.ReadLine();
userNumber = Convert.ToDouble(stringUserNumber);
if (userNumber > randomNumber)
Console.WriteLine("Your number is {0} higher than generated number which is {1}", userNumber, randomNumber);
if ( userNumber < randomNumber)
Console.WriteLine("Your number is {0} lower than generated number which is {1}", userNumber,randomNumber);
if (userNumber == randomNumber)
Console.WriteLine("OH WOW YOUR NUMBER IS {0} AND GENERATED NUMBER IS {1}", userNumber, randomNumber);