Questions
in c++ please In this program you are going to have several files to turn in...

in c++ please

In this program you are going to have several files to turn in (NOT JUST ONE!!)

  • hangman.h – this is your header file – I will give you a partially complete header file to start with.
  • hangman.cpp – this is your source file that contains your main function
  • functions.cpp – this is your source file that contains all your other functions
  • wordBank.txt – this is the file with words for the game to use.  You should put 10 words in this text file.

COMPILE THIS WAY:
g++ -Wall -std=c++11 hangman.cpp functions.cpp –o hangman

PROGRAM DESCRIPTION:

You will create a C++ program that will allow the user to play the game Hangman.  Hangman is traditionally a paper & pencil game.  One player thinks of a word and the other player tries to guess it by suggesting letters that may be in the word.  Your program will be player one, by pulling a word from a “word bank” and then player two is the user of your program.  The game is over when one of two things happen:

  • The user correctly completes the word.
  • The user incorrectly guesses a letter six times.

ARRAYS

You will have four arrays.  Three of the arrays will be C-Strings (NOT C++ STRING CLASS STRINGS!!!).  

  • Character array of size 21 (20 characters plus one null-terminator) that will hold the word read in from the “word bank”.  You may assume that the game only plays with words, not phrases.  (No spaces).
    char word[21];
  • Character array of size 21 (20 characters plus one null-terminator) that will at first hold all underscores.  Then, as the user makes correct guesses, the underscores will be replaced with the correct letters.  This means you will have to assign each element to an underscore ‘_’  before the user starts to make any guesses.
    char underScores[21];
  • Character array of size 27 (26 characters plus one null-terminator).  Initialize this array when you define it to all the uppercase letters in the alphabet.  â€œABCDEFGHIJKLMNOPQRSTUVWXYZ”.  
    char alphabet[27] = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
  • Boolean array of size 26 (26 boolean values).  This array will have a true/false toggle for each letter of the alphabet.  If the user has guessed the letter B, then this array at element 1 will have the value of true.  Assign false to each element before the user starts to make any guesses.  
    bool userGuesses[26];

WORD BANK

You will have to create an input file called wordBank.txt.  You need to manually type in TEN or more words to this file.  Your program will not be outputting to this file.  wordBank.txt will be used as an input file only.  Here is one of my wordBank.txt files to see what I mean.  Please do not use my words – make up your own!

FUNCTION:  INT MAIN()

  • Open the input file wordBank.txt.  If the file can’t open, print out a message that a word could not be found in the word bank.
  • Allow the user to play this game (run the program) multiple times.  

SETTING UP FOR THE GAME

  • Set all the elements of the userGuesses array to false
  • Using a loop, set all elements of the underScores array to the underscore character ‘_’.  
  • Set the stage variable to zero (the starting stage)
  • Read in a word from the input file (get the word) – make sure that if the user runs the program multiple times that they get a different word each time from the file.

GAME PLAY

  • While the game has not ended (user is not at stage 6 yet and they have not guessed the word), then do the following:
    • Call the printWord function sending the word array and the underScores array as arguments.
    • Call the printStage function sending the stage variable as an argument.
    • Call the printLettersGuessed function sending the userGuesses array and alphabet array as arguments.
    • Ask the user for their guess.  If it is a lowercase letter, then you need to make it an uppercase letter.  
      cout << “  WHAT LETTER DO YOU GUESS?  â€œ;
      cin >> letter;
      letter = toupper(letter); //the toupper function will make letter uppercase.

      Make sure the letter is not a letter already guessed.  If it is a letter they have already guessed, then force the user to enter in a different letter.  
    • Take the usersGuesses array and make the letter they just guessed true instead of false.  For example, if they guessed the letter ‘C’ then you will need to make usersGuesses[2] = true;
    • Find out if the letter that they guessed is inside the chosen word from the word bank.
      • If the letter guessed is found in the word array, then print out CORRECT! And then put the letter in the underScores array in the same location as the wordFromFile array.
        underScores[x] = word[x];  // where x is an integer incremented by the for loop.
      • If there were no letters found, then print out WRONG!, increment the stage number.  If the stage number is already 6, then call the printStage() function.
      • Tell the user to press enter to continue.
    • Find out if the user has guessed every letter in the word, because if they have, then the game is done and the loop will stop.  
      • Find out the length of the chosen word
        wordLength = strlen(word);
      • Do a special string comparison that will compare two words up to a given length.  The function is strncmp() that you will need to use.  If the chosen word (word array) and theunderScores array match, then the user has guessed the word and the game is over.  Print out a message that the user won the game.

Function:  void printStage(int)

This function will accept as a parameter the current stage and print out the respective diagram to the screen.  Each time the user guesses, a diagram is printed out.  The diagram represents the user being closer and closer to being “hanged” – which is why the game is called Hangman.  At the beginning of the game, the diagram starts at stage 0.  The user will stay at stage 0 (zero) until he or she guesses incorrectly, and then he/she will advance one stage to stage 1.  There are 7 stages (stage 0 to stage 6) to represent the user guessing incorrectly six times.  If the user gets to stage 6, they lose the game.  I have already provided this function for you!

Function:  void printWord(char[], char[])

This function will print out the letters in the word that have already been correctly guessed.  At the beginning of the game, this function should just print out underscores to represent each letter.  This lets the user know how many letters is in the word they are trying to guess.

WORD:  _ _ _ _ _ _ _

Then, as the user guesses a letter, replace the underscore with the letter:

WORD:  W _ _ _ _ _ _

How the function should work:

  • Figure out the length of the character array word (use strlen c-string function)
  • Use a loop to go through as many iterations as the length of word
    • Print out each character of the underScores[] array.  It should be the same length as word.
    • For example, if the word array is ‘R’’A’’V’’E’’N’, then the string length is 5.  Write a for loop that will iterate five times printing out the characters in underScores[] array.  The underScores array may have more than 5 characters in it, but you will only print out 5.

Function:  void printLettersGuessed(bool[], char[])

This function will print out all the letters the user has guessed so far (correct & incorrect).

LETTERS YOU HAVE ALREADY GUESSED:  Q W X Z

How the function should work:

  • Starting at 0, for every element up until 25, if the current element of usersGuesses is true, then output the letter (from the alphabet array) of the same element.  
  • Make sure you print out: “ LETTERS YOU HAVE ALREADY GUESSED:  â€œ before you print out the letters.

In: Computer Science

For this project, you are going to write a program to find the anagrams in a...

For this project, you are going to write a program to find the anagrams in a given dictionary for a given word. If two words have the same letters but in different order, they are called anagrams. For example, “listen” and “silent” are a pair of anagrams.

**JAVA**

First let’s focus on “LetterInventory.java”.

Its purpose is to compute the canonical “sorted letter form” for a given word.

1. Implement the constructor, which takes the String input word. You can assume that the input word contains only valid letters (e.g. no punctuation or blanks), but it may contain letters in different cases.

2. Implement the method: public String getCanonical() It should return the canonical “sorted letter form” for the input word (given in the constructor). It should use only lower cases. For example, if the given word is “AliBaba”, then this method should return “aaabbil”.

****I have already completed all of the above tasks I am struggling with the next part****

**below is the code I have for LetterInventory.java**

import java.util.*;

public class LetterInventory {

   private String input;
  
   //stores the original word.
  
   public LetterInventory(String input) {
       this.input = input;
   }
   //uses an array of chars to hold word and sorts it into alphabetical order.
   //displays it in lower case.
public String getCanonical() {
   input = input.toLowerCase(); // converting input to lower case
   char [] word = input.toCharArray();
   Arrays.sort(word);
   String sorted = new String (word);
   return sorted;
  
}
}

*** this is where i am stuck ***

Once “LetterInventory.java” is working as expected, we can now focus on “AnagramFinder.java”. It will read an input “dictionary” file, which contains quite many words, to build a map. The “key” for the map is a word’s canonical form, the “value” for the map will be all the words in the given dictionary that share the same canonical form. For example, if both “listen” and “silent” are in the dictionary, one entry in the map would have key as “eilnst” and value as an ArrayList of words “listen” and “silent”.

Implement the constructor, which takes in the input dictionary file and build the map. You can assume the words in the dictionary contain only valid letters. You should take advantage of “LetterInventory”.

3. Now implement the method: public void printAnagrams(String word) It should try to search the anagrams for the given word in the map. Again, you can assume the input word contains only valid letters, and you should take advantage of “LetterInventory”.

Print out any anagrams found. For now, don’t worry about the case where the input word is the same as the word inside the dictionary, just print them out.

Here is some sample print out:

Your input is: silent. Found anagrams: listen, silent, tinsel.

Your input is: AliBaba. Sorry, didn’t find any anagrams.

A sample main method is already written for you to test various functionalities with some sample input words.

*** Below is the shell for the main method ***

import java.io.*;
import java.util.*;

public class AnagramFinder {
public static void main(String[] args) throws FileNotFoundException {
String[] originals = new String[] {
"realfun",
"mias",
"EVIL",
"unable",
"Silent",
"AliBaba"
};

for(String original: originals) {
LetterInventory inv = new LetterInventory(original);
System.out.println("Original: " + original + ", Canonical: " + inv.getCanonical());
}

System.out.println("\n");

File f = new File("HW_sample_dict.txt");

AnagramFinder finder = new AnagramFinder(f);

for(String original: originals) {
finder.printAnagrams(original);
}
}

public AnagramFinder(File f) throws FileNotFoundException {
//TODO implement  
}

public void printAnagrams(String word) {
//TODO implement
}

public void printAnagrams2(String word) {
// Extra Credit: optional to implement
}
}

** can leave out extra credit part i just need help with the first 2 methods in the main file **

** the dict.txt is 400 pages long so I did not include it (the file just contains thousands of words) **

In: Computer Science

find 15 words associated with gallbladder and break them down according to the prefix/word root or...

find 15 words associated with gallbladder and break them down according to the prefix/word root or combining form/ suffix and their meaning of the word.

In: Nursing

Write a hangman program in c++.The game is played as follows: 1. The program selects a...

Write a hangman program in c++.The game is played as follows:

1. The program selects a random word for the user to guess (Read words for the user to guess into an array of strings from a file. The words are: revolutionary, meaning, recovery, compartment, trainer, pursuit, harm, platform, error, confusion)

2. User guesses one letter at a time until either they guess the word, or they run out of guesses.

3. Select a random word from the array of strings to the word the user has to guess.

Maintain 2 char arrays:

a. availableLetters: a char array of the available letters the user can choose their guess from. Initialize availableLetters as the lowercase alphabet. As the user guesses letters, replace the corresponding guessed letter with a space to denote the letter has already been guessed.

b. visibleLetters: a char array of the not guessed letters in the word. Initialize visibleLetter to all dashes ("-"). As the user correctly guesses a letter, replace the corresponding dash(es) with the correct letter.

4. The main game loop:

a. Display information regarding the status of the game (visibleLetters, availableLetters, and the number of incorrect guesses remaining (the user gets 7 incorrect guesses)).

b. Prompt the user to enter their guess. If the user tries to guess a letter they have already guessed, inform the user and re-prompt.

c. Exit the loop if the users completely guesses the letters of the word or if the user runs out of incorrect guesses.

Note: relevant string methods you will likely need to use for this program are <string variable>.at(i) to get a character at index position and i and <string variable>.size() (or <string variable>.length() to get the number of characters in the string.

Example output:

The word to guess has 5 letters.

----- 
Available letters: abcdefghijklmnopqrstuvwxyz
7 incorrect guesses remaining.
Please enter your guess: 
s
s is not in the word. Too bad. 6 incorrect guesses remaining.

----- 
Available letters: abcdefghijklmnopqr tuvwxyz
6 incorrect guesses remaining.
Please enter your guess: 
e
Nice! e is in the word.

-e---
Available letters: abcd fghijklmnopqr tuvwxyz
6 incorrect guesses remaining.
Please enter your guess: 
r
r is not in the word. Too bad. 5 incorrect guesses remaining.

-e---
Available letters: abcd fghijklmnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
r
r is not an available letter

-e---
Available letters: abcd fghijklmnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
l
Nice! l is in the word.

-ell-
Available letters: abcd fghijk mnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
h
Nice! h is in the word.

hell-
Available letters: abcd fg ijk mnopq  tuvwxyz
5 incorrect guesses remaining.
Please enter your guess: 
o
Nice! o is in the word.
Congrats, you guessed the word hello!

In: Computer Science

Use this constant dictionary as a global variable: tile_dict = { 'A': 1, 'B': 3, 'C':...

Use this constant dictionary as a global variable:

tile_dict = { 'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, 'S': 1, 'T': 1, 'U': 1, 'V': 4, 'W': 4, 'X': 8, 'Y': 4, 'Z': 10 }

Implement function scrabblePoints(word) that returns the calculated points for the word based on the tile_dict above. The word parameter is a string. This function takes the string and evaluates the points based on each letter in the word (points per letter is set by the global dictionary). P or p is worth the same points. No points calculated for anything that is not A-Z or a-z.

[You may use upper() and isalpha() ONLY and no other method or built-in function]

Examples:

word = “PYTHON”

print(scrabblePoints(word))

returns:

14

word = “hello!!”

print(scrabblePoints(word))

returns:

8

word = “@#$=!!”

print(scrabblePoints(word))

returns:

0

Note: This function relies on scrabblePoints. Function you solved in Question 2.

Implement function declareWinner(player1Word = “skip”, player2Word = “skip”) that returns either “Player 1 Wins!”, “Player 2 Wins!”, “It’s a Tie”, “Player 1 Skipped Round”, “Player 2 Skipped Round”, “Both Players Skipped Round”. The player1Word and player2Word parameters are both type string. Assume input is always valid. This function should call on the function scrabblePoints to earn credit.

[No built-in function or method needed]

Examples:

player1Word = “PYTHON”

player2Word = “Pizza”

     print(declareWinner(player1Word, player2Word))

     returns:           

     Player 2 Wins!

              print(declareWinner(player1Word))

              returns:           

              Player 2 Skipped Round

Please do the second function only. I just needed to add the first function for reference

In: Computer Science

Please discuss the following question in your own word 300 word count on the following question....

Please discuss the following question in your own word 300 word count on the following question.

Continuous process improvement is a significant step in Kotter's last step "make it stick". The last step defines the cultural change for the organization and is marked by employee buy-in, leadership's ability to motivate staff towards change, and redefining the organization's position on the "process change". As a future health care leader you create the vision and point your staff to the path towards process change. What motivational techniques might you use to encourage your staff to embrace change and engage in the ongoing process of process improvement?

In: Nursing

in basic c++ program please!! Write a word search and word count program. Assign the following...

in basic c++ program please!!

Write a word search and word count program.

  1. Assign the following text to a string constant.

For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life. For God did not send his Son into the world to condemn the world, but to save the world through him.Whoever believes in him is not condemned, but whoever does not believe stands condemned already because they have not believed in the name of God’s one and only Son. This is the verdict: Light has come into the world, but people loved darkness instead of light because their deeds were evil. Everyone who does evil hates the light, and will not come into the light for fear that their deeds will be exposed. 21 But whoever lives by the truth comes into the light, so that it may be seen plainly that what they have done has been done in the sight of God.

  1. Prompt the user to enter a word or phrase
  2. Search the string given by the user from the text above and inform how many times the word/phrase was found in the text.

(Hint: You need to use while loop, .find and .length function from string library. Also, you will need to use string::npos.)

  1. Your SOURCE CODE (.cpp file ONLY, such as main.cpp, filename.cpp. It is NOT .sln or any other extensions)
  2. Search for the following (ALL strings are CASE-SENSITIVE!)
    1. God
    2. the world
    3. believe
    4. Jesus
    5. only Son
    6. life

  

In: Computer Science

3. Microsoft’s Word program enjoys a 94% share of the word processing market, which is considered...

3. Microsoft’s Word program enjoys a 94% share of the word processing market, which is considered a monopoly. Are they taking advantage of any of the usual practices that we associate with monopolies (if so—what)? Do you think something should be done about their dominance, or is this a monopoly the world should accept?

In: Economics

I have a Python code that reads the text file, creates word list then calculates word...

I have a Python code that reads the text file, creates word list then calculates word frequency of each word. Please see below:

#Open file

f = open('example.txt', 'r')

#list created with all words

data=f.read().lower()

list1=data.split()

#empty dictionary

d={}

# Adding all elements of the list to a dictionary and assigning it's value as zero

for i in set(list1):

    d[i]=0

# checking and counting the values

for i in list1:

    for j in d.keys():

       if i==j:

          d[i]=d[i]+1

#Return all non-overlapping matches of pattern return pattern

print(d)

Question: How do I have my code only calculate specific list of words not the every single word in the file. for example: I only wanna know how many times (Apple, Banana, Orange, Watermelon, Blueberry) occurred throughout the text. Also apple/Apple/Apple! should count as same word. I appreciate your help. Please don't comment if you don't want to work on this question.

Here is the example text file: named example.txt

I Love apple, I don't like banana, but blueberry for me too. Apple, banana, orange, watermelon are my fav.
Banana can keep you full. Watermelon is good for summer. Banana!

In: Computer Science

(IN YOUR WORD) write a 400-word long, five paragraph effect of student cheating. (supported with a...

(IN YOUR WORD) write a 400-word long, five paragraph effect of student cheating.

(supported with a clear thesis statement and five well-developed paragraphs)

In: Psychology