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

Finish the following hangman C++ program and make it run well as well as comment

ID: 3533327 • Letter: F

Question


Finish the following hangman C++ program and make it run well as well as comment the program through to help me understand the code perfectly without unclear steps.

#include <stdlib.h>

#include <stdio.h>

#include <time.h>

#include <string>

#include <fstream>

#include <iomanip>

#include <math.h>

#include <Ctime>

#include <iostream>


constint numwords = 34;


void DrawBody(int bodysize);


usingnamespacestd;

constint WORDSIZE = 6;

constint BODYSIZE = 6;

int main(int argc, constchar * argv[])

{

  ifstream wordlist;

wordlist.open("wordlist.txt");

  if (!wordlist)

{

cout << "couldn't find word list";

  return1;

}

  int whichword = rand()%(numwords)+1;

  string nextwordstring;

  string word;

  int dotlocation = nextwordstring.find(".");

  while(nextwordstring.substr(0,dotlocation) != "4")

{wordlist >> nextwordstring;

  int dotlocation=nextwordstring.find(".");

word = nextwordstring.substr(dotlocation+1);

}

  cout << word;

// string word = "tester";

  char wordA[WORDSIZE]= {'t','e','s','t','e','r'};

bool correctA[WORDSIZE] = {false, false, false, false, false, false};

  int bodyCount = 0;

  int numCorrect = 0;

  char userGuess;

  while ((bodyCount < BODYSIZE) && (numCorrect < WORDSIZE))

{

  cout << "letter: ";

  cin >> userGuess;

  bool foundone = false;


  for(int i=0; i<WORDSIZE; i++)

{

  if (userGuess == wordA[i])

{

correctA[i] = true;

foundone = true;

numCorrect++;

}

}

  if (not foundone)

bodyCount++;

  cout << "bodycount = " << bodyCount << endl;

  DrawBody(bodyCount);

  for(int i=0; i<WORDSIZE; i++)

  if (correctA[i])

  cout << wordA[i];

  else

  cout << "_";

  cout << endl;

}

  if (bodyCount >= BODYSIZE)

  cout << "you lose";

  else

  cout << "you win";

  return0;

}


void DrawBody(int bodysize)

{

  cout << "|-----|"<<endl;

  switch (bodysize){

  case1:

  cout <<"| O"<<endl;

  cout <<"| "<<endl;

  cout <<"| "<<endl;

  cout <<"| "<<endl;

  cout <<"| "<<endl;

  break;

  case2:

  cout <<"| O"<<endl;

  cout <<"| |"<<endl;

  cout <<"| "<<endl;

  cout <<"| "<<endl;

  cout <<"| "<<endl;

  case3: cout <<"|"; break;

  cout <<"| O"<<endl;

  cout <<"| /|"<<endl;

  cout <<"| "<<endl;

  cout <<"| "<<endl;

  cout <<"| "<<endl;

  break;

  case4:

cout <<"| O"<<endl;

  cout <<"| |"<<endl;

  cout <<"| /|\"<<endl;

  cout <<"| "<<endl;

  cout <<"| "<<endl;

  break;

}

}

========

text file of words:


1.abduce

2.abduct

3.abjure

4.ablest

5.abound

6.absurd

7.abused

8.abuser

9.acetyl

10.acquit

11.acuity

12.aculei

13.acumen

14.acuter

15.adieux

16.adjoin

17.adjure

18.adjust

19.advent

20.adverb

21.advert

22.advice

23.advise

24.afield

25.agnize

26.agonic

27.aguish

28.akimbo

29.albino

30.albite

31.alcove

32.alexin

33.algoid

34.alined

Explanation / Answer

I am working on this...will take sometime. u can also contact me on timacs12@gmail.com

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