Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make a \"hangman\" game with the following stipulations (1) Create an internal d

ID: 3531598 • Letter: M

Question

Make a "hangman" game with the following stipulations (1) Create an internal dictionary of words and phrases; include at least 20 valid entries, each with at least 8 characters (excluding blank spaces). There should be at least five phrases. Store dictionary as an array of pointers to strings. (2) Randomly choose word from dictionary and prompt user to guess one character at a time. Each letter in the word or phrase is initially displayed as an asterisk; for phrases, show the non-alphanumeric characters (e.g., commas). When the user makes a correct guess, the actual character is displayed. (3) Include appropriate help messages, e.g., inform user when the chosen character is not in the word/phrase, and when the user has already chosen this character before. (4) When the user finishes the word or phrase, display statistics regarding the number of hits and misses. (5) At the end of one round of the game, user can decide either to terminate the game or to play one more round of the game.

Explanation / Answer



#include<iostream>

#include <stdlib.h>

#include<string.h>

#include<conio.h>

using namespace std;


void printer(char answer, char correct, char incorrect, int count, int tries, char star[]){

if(correct ==answer){

cout<<"Letter " <<answer<<" exists "<<count<<" times in the secret word, You have "<< tries<<" tries left. ";

cout<<star<<" ";


}


else{

cout<<"Letter "<<answer<<" is not part of the secret word, You have "<<tries<<" tries left ";

cout<<star<<" ";


}

}


void lettercheck(char answer, char word[], char star[], int& tries){

int i;

char correct=' ';

char incorrect=answer;

int count=0;

for(i = 0; word[i]; i++){



if(word[i] == answer){


correct = answer;

star[i] = answer;

count++;

}



}

tries=tries-1;

printer(answer,correct,incorrect,count,tries,star);

}

int main(){

//dictionary creation

char* dictionary[20]={

"abjure",

"abrogate",

"abstemious",

"acumen",

"antebellum",

"auspicious",

"belie",

"bellicose",

"bowdlerize",

"lugubrious",

"metamorphosis",

"mitosis",

"moiety",

"nanotechnology",

"nihilism",

"a daniel come to judgement",

"all of a sudden",

"a sea change",

"all one to me",

"all corners of the world",

};

int r;

char choice;

int k;

do

{

r=rand() ;

cout<<r<<endl;

char* word=dictionary[r];

for(k=0;word[k];k++);

char* star= new char[k];


for(k=0;word[k];k++)

star[k]='*';

star[k]='';




char answer=' ';

int tries =k;


cout<<"Hi, let's play hangman"<<" The secret word is: ";

cout<<star;

cout<<" Guess a letter: ";



do

{


cin>>answer;


lettercheck( answer, word, star, tries);

if(strcmp(star,word)==0)

{

cout<<" you have sucessfully guesed the word ";

break;

}

if(tries==0)

cout<<" you remain unsucessfull in guesing the word ";



}while(tries!=0);

cout<<" select one of the option ";

cout<<" C .continue ";

cout<<" E.Exit ";

cin>>choice;


}while(choice!='E');


return 0;


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote