Question
This is Matlab. Need answers with proper comments, please. Thanks

In this part, you need to write a simplified Hangman game: https:/len.wikipedia.org/wikilHangman (gamee WSA9 part5 Welcome to a simplified Hangman-style guessing g Here is a random word selected from the 100 most common nouns in the English language. For this, you will need to find and download a dictionary of the 100 most common English nouns and Pleas uess a letters Nothing guessed, exitting... > WSA9 parts store as a cell array of strings. (You can search the no Internet for these- there is no right or wrong collectonome to a simplified Hangman-style quessing ga of words) Here is a random word selected from the 100 most common nouns in the English language. Your game will then randomly select one of these words to display to the user as blanks (underscores),ase guess a letter e and prompt the user to guess letters. Please guess a letter: a Letter not found. Try again. Please guess a letter: i If a letter is not found, display a message. If found, replace the appropriate underscores with the letter. If Please quess a 1 a letter has been guessed before, alert the user. a i Please guess a letter: u Letter not found. Try again Additional error-checking isnt required in this example || i-o-a-i。 just assume the user enters only single characters Please quess a letter: t or they can press the return/enter key to exit. oatio Please guess a letter: That letter has already been guessed, try again. Please guess a letter:n i n o Please guess a letter: f nto cation Please guess a letteri r infor ation Please guess a letter: information Congratulations, you win atio n
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:::

clc
clear

disp("Welcome to a simmplified handman-style guessing game.");
disp("Here is a random word selected from the most 100 common nouns in the English language");

fileID = fopen('100Words.txt','r');
record = textscan(fileID,'%s','Delimiter','\n');
words = record{1};
random = randi(100);

word = words{random};
len = length(word);
guessString =zeros(1,len);
guessRecord=[];
for i = 1:len
if guessString(i)==0
fprintf("_ ");
end
end
fprintf("\n");
while 1
letter = input('Please guess a letter : ','s');
if letter==""
disp("Nothing guessed, exiting...");
return;
else
k = strfind(guessRecord,letter);
if k~=0
disp("The letter has already been guessed, try again");
continue;
end
guessRecord = [guessRecord,letter];
found = 0;
for i = 1:len
if word(i)==letter
guessString(i) =word(i);
found=1;
end
end
if found==0
disp("Letter not found. Try again.");
else
for i = 1:len
if guessString(i)==0
fprintf("_ ");
else
fprintf("%c ",guessString(i));
end
end
fprintf("\n");
end
end
if guessString==word
disp("Congratulations, you win!");
break;
end
end

---------------------------------

100Words.txt

man
year
came
show
every
good
me
give
our
under
name
very
through
just
form
sentence
great
think
say
help
low
line
differ
turn
cause
much
mean
before
move
right
boy
old
too
same
tell
does
set
three
want
air
well
also
play
small
end
put
home
read
hand
port
large
spell
add
even
land
here
must
big
high
such
follow
act
why
ask
men
change
went
light
kind
off
need
house
picture
try
us
again
animal
point
mother
world
near
build
self
earth
father
head
stand
own
page
should
country
found
answer
school
grow
study
still
learn
plant
cover

===========================

=========================

output:

Command Window Welcome to a simmplified handman-style guessing Here is a random word selected from the most 100 Please guess a letter: a Please guess a letter : i Please guess a letter : n Please guess a letter : i The letter has already been guessed, try again Please guess a letter: f inf Please guess a letter o i nfo Please guess a letter r inf or a io n Please guess a letter : m inf orma io n Please guess a letter:t inf ormat io n Congratulations, you win! a i o n

Add a comment
Know the answer?
Add Answer to:
This is Matlab. Need answers with proper comments, please. Thanks In this part, you need to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Do in Python please provide screenshots aswell. Here are the requirements for your game: 1. The...

    Do in Python please provide screenshots aswell. Here are the requirements for your game: 1. The computer must select a word at random from the list of avail- able words that was provided in words.txt. The functions for loading the word list and selecting a random word have already been provided for you in ps3 hangman.py. 2. The game must be interactive; the flow of the game should go as follows: • At the start of the game, let the...

  • Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program...

    Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program 3 - Hangman Game Assignment purpose: User defined functions, character arrays, c style string member functions Write an interactive program that will allow a user to play the game of Hangman. You will need to: e You will use four character arrays: o one for the word to be guessed (solution) o one for the word in progress (starword) o one for all of...

  • This is for C programming: You will be given files in the following format: n word1...

    This is for C programming: You will be given files in the following format: n word1 word2 word3 word4 The first line of the file will be a single integer value n. The integer n will denote the number of words contained within the file. Use this number to initialize an array. Each word will then appear on the next n lines. You can assume that no word is longer than 30 characters. The game will use these words as...

  • //SCROLL TO BOTTOM FOR WAYS TO GET A MEETING AND AN EXCEEDING var secretWord = "secretword"...

    //SCROLL TO BOTTOM FOR WAYS TO GET A MEETING AND AN EXCEEDING var secretWord = "secretword" function setup() { createCanvas(400, 400); background(220); } function draw() {    rect(100,150,100,70) text("Click to \nstart hangman",110,175)    rect(225,150,100,70) text("Click to \nguess letter",235,175)    } function mousePressed(){ if(mouseOnRect(100,150,100,70)){ //begin hangman game //create variable to hold secret word as an array split by letter //create variable to hold display word as an array of * or _ that takes the place of each letter //get the...

  • Overview In this exercise you are going to recreate the classic game of hangman. Your program...

    Overview In this exercise you are going to recreate the classic game of hangman. Your program will randomly pick from a pool of words for the user who will guess letters in order to figure out the word. The user will have a limited number of wrong guesses to complete the puzzle or lose the round. Though if the user answers before running out of wrong answers, they win. Requirements Rules The program will use 10 to 15 words as...

  • Please create a Hangman game in Java language. For this game a random word will be...

    Please create a Hangman game in Java language. For this game a random word will be selected from the following list (abstract, cemetery, nurse, pharmacy, climbing). You should keep a running tab of the user’s score and display it on screen; the user begins with 100 pts possible if they correctly guess the word without any mistakes. For every incorrect letter which is guessed, 10 pts should be taken away from what is left of their total possible points. For...

  • I have to use java programs using netbeans. this course is introduction to java programming so...

    I have to use java programs using netbeans. this course is introduction to java programming so i have to write it in a simple way using till chapter 6 (arrays) you can use (loops , methods , arrays) You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...

  • JAVA Hangman Your game should have a list of at least ten phrases of your choosing.The...

    JAVA Hangman Your game should have a list of at least ten phrases of your choosing.The game chooses a random phrase from the list. This is the phrase the player tries to guess. The phrase is hidden-- all letters are replaced with asterisks. Spaces and punctuation are left unhidden. So if the phrase is "Joe Programmer", the initial partially hidden phrase is: *** ********** The user guesses a letter. All occurrences of the letter in the phrase are replaced in...

  • Create the game hangman using c code: Program description In the game of hangman, one player...

    Create the game hangman using c code: Program description In the game of hangman, one player picks a word, and the other player has to try to guess what the word is by selecting one letter at a time. If they select a correct letter, all occurrences of the letter are shown. If no letter shows up, they use up one of their turns. The player is allowed to use no more than 10 incorrect turns to guess what the...

  • For this assignment, you will create a command-line version of the game Hangman. For this assignment...

    For this assignment, you will create a command-line version of the game Hangman. For this assignment you will research on StringBuilder Class (Use this link) and use it in your code. Please finish the program in Java Language Your game should have a list of at least ten phrases of your choosing (appropriate to all audiences please!) The game chooses a random phrase from the list. This is the phrase the player tries to guess. (10) ● The phrase is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT