Prgram has to be written in C#. Any directions would be appreciated. IS162AD: Ch
ID: 3591155 • Letter: P
Question
Prgram has to be written in C#. Any directions would be appreciated.
IS162AD: Chapter5 Assignment-GuessingGame Programming Exercise 14 (pg. 225) Write a program named GuessingGame that generates numbers between 1 to 10. (In other words min is 1 and max is 11. You can choose any min and max value for your program). Ask a user to guess the random number, display a message indicating whether the guess is too low, too high, or correct. If the user does not guess the correct number continue to enter values until the correct guess is made. After the user guesses correctly, display the number of guesses made HE UESSING 1-100 GAME Hint: Random numbers can be generated using the Random class Random ranNumberGenerator- new Random) int randomNumber randomNumberranNumberGenerator.Next(min, max); Sample Output Enter a number between 1 and 10>>8 Your guess was too high Guess again >>5 Your guess was too high Guess again >>3 Your guess was correct! You got it in 3 guesses. Your program should include your Full Name, Assignment Name, Date and description as a comment on the top of your application. Submit GuessingGame.cs file.Explanation / Answer
using System.IO;
using System;
class Program
{
static void Main()
{
int n, guessCount = 0;
Random rnd = new Random();
int randNum = rnd.Next(1, 10);
Console.WriteLine("Enter a number between 1 and 80: ");
n = Convert.ToInt32(Console.ReadLine());
while(n != randNum) {
if(n < randNum) {
Console.WriteLine("You guess was too low");
} else if(n > randNum) {
Console.WriteLine("You guess was too high");
}
guessCount++;
Console.WriteLine("Enter a number between 1 and 80: ");
n = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("You guess was correct");
Console.WriteLine("You got it in "+guessCount+" guesses");
}
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.