in c++ please
In this program you are going to have several files to turn in (NOT JUST ONE!!)
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:
ARRAYS
You will have four arrays. Three of the arrays will be C-Strings (NOT C++ STRING CLASS STRINGS!!!).
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()
SETTING UP FOR THE GAME
GAME PLAY
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:
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:
In: Computer Science
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
In: Nursing
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': 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.
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.
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.
(Hint: You need to use while loop, .find and .length function from string library. Also, you will need to use string::npos.)
In: Computer Science
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 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 clear thesis statement and five well-developed paragraphs)
In: Psychology