Question
Create IPO Chart for the following code. static void Main(string[] args) { string word = happy; char[] array = new char[word.Length]; for (int i =
Create IPO Chart for the following code.
static void Main(string[] args) { string word = "happy"; char[] array = new char[word.Length]; for (int i = 0; i < word.Length; i++) array[i] = '*'; Console.WriteLine("Welcome to the hangman game! "); int score = 0; for (int j = 0; j < 10; j++) { Console.WriteLine(array); Console.WriteLine("Enter a letter please"); //char ch = (char) Console.Read(); string str = Console.ReadLine(); int found = 0; for (int i = 0; i < word.Length; i++) { if (str[0] == word[i]) { array[i] = word[i]; found = 1; } } if (found == 0) { Console.WriteLine("You guessed incorrectly!"); } else { // Score is used keep track of how many letters are in the guessed array score++; Console.WriteLine("You guessed a letter correctly!"); } if (word.Equals(new string(array))) { Console.WriteLine(array); Console.WriteLine("Congratulations! You have figured out the word! "); Console.ReadLine();//To keep console window open, your last line of code } } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started