I\'m writing a program for a guessing game using c# where I have to guess the wo
ID: 3806251 • Letter: I
Question
I'm writing a program for a guessing game using c# where I have to guess the words from the topics animals, vegetables, and minerals. attached are the specs. can anyone help me
Explanation / Answer
using System; namespace GuessingGame { class Game { static int Guess = 0; static int Target = 5; static string Input = ""; static Random RandomNumber = new Random(); public static void Play() { Target = RandomNumber.Next(10) + 1; Console.Write("Guess what number I am thinking of... "); Input = Console.ReadLine(); if (int.TryParse(Input, out Guess)) { if (Guess == Target) { Console.WriteLine("Congratulations! You guessed " + Guess + " and the number I was thinking of was " + Target + "."); } else { Console.WriteLine("Too bad. You guessed " + Guess + " and the number I was thinking of was " + Target + ". Try again!"); } } else { Console.WriteLine("Please enter a number."); Console.WriteLine("Press enter to continue..."); Console.ReadLine(); Play(); } Console.Read(); } } class Program { static void Main() { Game.Play(); } } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.