Question: Need help in getting code to work properly please help. in c# Modify the design and program to test if each letter the user entered
Need help in getting code to work properly please help.
in c# Modify the design and program to test if each letter the user entered is one of the letters in the word. If the letter guessed is in the word, display a message to the user that they guessed correctly, if not display a message that the user guessed incorrectly. Add a score variable that will keep track of the number of incorrect guesses. If the user guesses incorrectly, increment the score variable. example of program out put is
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace week4project { class Program { static void Main(string[] args) { char sletter; string secretword; Console.WriteLine("Welcome to the hangman game !");
Console.WriteLine("*****");
Console.WriteLine("Please Enter a letter"); secretword=Console.ReadLine(); char letter1 = 'h',letter2 = 'a' ,letter3 = 'p' ,letter4 = 'p' ,letter5 = 'y'; sletter = char.Parse(secretword); Console.WriteLine(); switch (sletter) { case 'h': Console.WriteLine("Enter a letter please :"); Console.ReadLine(); break; case 'a': Console.WriteLine("Enter a letter please :"); Console.ReadLine(); break; case 'p': Console.WriteLine("Enter a letter please :"); Console.ReadLine(); break; case 'y': Console.WriteLine("Enter a letter please :"); Console.ReadLine(); break; default: Console.WriteLine("you guessed incorrectly."); Console.ReadLine(); break; } } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
