Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of the word. Next, use the struct to store the word read from a text file call “word.txt” and the length of the word. Print out the word x number of times based on the length of the word as shown below. Also, print a statement with the length and determine if the string length has an odd number or even number of characters. You need to create your own text file and place in the proper folder.
For instance, if the file contains the string "Program", its length is 7, 7 is a odd number and it will be printed 7 times like the below. Print to the console like below
OUTPUT :
Program
Program
Program
Program
Program
Program
Program
The word "Program" has a length of 7 and has an odd number of character
In: Computer Science
Create a Visual Studio console project named exercise101. The main() function should prompt for the name of a text file located in the same directory as exercise101.cpp, and search for a word in the text file as follows:
Enter text file name:
Enter search word:
The program should print the number of occurrences of the word in the file:
occurrences of were found in If the file could not be opened then display:
File not found Use Stream file I/O as a guide to opening and reading a stream input file.
You should read the file word by word, where a word is a set of characters preceded and followed by white space including newlines.
Test you program by searching for the word "government" in the usdeclar.txt file available in Files / Source code / Exercise 10.1 Upload your exercise101.cpp source file to Canvas.
In: Computer Science
In: Computer Science
In this assignment you will be implementing a function that will find all single-word anagrams given a single word and a list of all words. In the starter code you will the starting source file anagram.cpp and the list of words wordlist.txt. You will need to implement the anagram() function which takes a string for the word to find anagrams of as the first parameter and a vector of strings containing a list of all words as the second parameter. The return value of anagram() will be a vector of strings containing all anagrams (including the parameter word if it is an actual word). There is a main function that will test the anagram() function as well as an already-implemented function loadWordlist() which will read in words from the specified file with the format by string-type parameter and return these words in a vector of strings. The anagram() function will take a word (string) and a wordlist of all words (vector of strings) and builds a dictionary/map where the key is a specific amount of times each letter occurs in a word and the associated value is a vector of strings containing all words using those letters (anagrams). You may either modify the Stringset class to be a dictionary (holding a key:value pair as opposed to just a key) or use the STL unordered_map structure. The main() function provided will test the anagram() function with a word the user types in using the words stored from wordlist.txt in wordlist, for example if the user types in steak, anagrams=anagram("steak",wordlist); will run and if implemented correctly the following contents of anagrams will be displayed:
skate stake steak takes teaks
Submit anagram.cpp with the implemented anagram() function. You are free to implement any helper functions in anagram.cpp.
Anagram.cpp:
#include
#include
#include
#include
using namespace std;
vector loadWordlist(string filename);
vector anagram(string word, vector wordlist);
int main()
{
vector words;
vector anagrams;
string inputWord;
words=loadWordlist("wordlist.txt");
cout << "Find single-word anagrams for the following word:
";
cin >> inputWord;
anagrams = anagram(inputWord, words);
for (int i=0; i {
cout << anagrams[i] << endl;
}
return 0;
}
vector loadWordlist(string filename)
{
vector words;
ifstream inFile;
string word;
inFile.open(filename);
if(inFile.is_open())
{
while(getline(inFile,word))
{
if(word.length() > 0)
{
words.push_back(word);
}
}
inFile.close();
}
return words;
}
vector anagram(string word, vector wordlist)
{
}
Stringset Class:
class Stringset
{
private:
vector<list<string>> table;
int num_elems;
int size;
public:
Stringset();
vector<list<string>> getTable() const;
int getNumElems() const;
int getSize() const;
void insert(string word);
bool find(string word) const;
void remove(string word);
};
In: Computer Science
Write a program that translates an English word into a Pig Latin word. Input ONE, and ONLY one, word from the user, and then output its translation to Pig Latin.
The rules for converting a word to Pig Latin follow.
Use at least the REQUIRED METHODS listed below, with the exact same SPELLING for method names and parameters.
Input Specification
Input ONE English word as a string. If multiple words are entered ignore any beyond the first.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING.
Please enter a word ==>
Output Specification
Output an introductory message, a prompt for the English word, and a translation for the inputted word.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING. The output below assumes the user entered "Hunger".
This program will convert an English word into Pig Latin. Please enter a word ==> Hunger "Hunger" in Pig Latin is "unger-Hay"
Required Methods
// Prompt and read a word to translate public static String readWord (Scanner console) // Convert a word to Pig Latin and return it public static String convertWord (String englishWord) // Return true if "c" is a vowel, false otherwise. // Handle both lowercase and uppercase letters. public static boolean isVowel (char c) // Print result of translation public static void printResult (String englishWord, String pigLatinWord)
Hints
BEFORE you start coding, think about which methods each method will call. Which methods should "main" call? Create a diagram which shows the calling relationships.
There are many useful String methods listed HERE. You may find startsWith and charAt helpful.
Style
Write comments
In: Computer Science
Assume a 222 byte memory:
a. What are the lowest and highest addresses if memory is byte-addressable?
b. What are the lowest and highest addresses if memory is word-addressable, assuming a 16-bit word?
c. What are the lowest and highest addresses if memory is word-addressable, assuming a 32-bit word?
Explain with Steps please
In: Computer Science
Pick at least one of the buttons or menu items in MS Word not covered in this class' Word Modules. What is its name, and where is it located in the MS Word interface? What does it do? How have you or might you use it in an MS Word document to make your work products better? Explain how to transform, or export, do a layout, design, or it can make a flyer or,insert, a document must be 230- 250-word discussion any one of these.
In: Computer Science
Write the following Python script:
Pikachu is a well-known character in the Pokemon anime series. Pikachu can speak, but only 3 syllables: "pi", "ka", and "chu". Therefore Pikachu can only pronounce strings that can be created as a concatenation of one or more syllables he can pronounce. For example, he can pronounce the words "pikapi" and "pikachu".
You are given a String word. Your task is to check whether Pikachu can pronounce the string. If the string can be produced by concatenating copies of the strings "pi", "ka", and "chu", return "YES" (quotes for clarity). Otherwise, return "NO".
Constraints:
Check your work with these examples:
-------------------------------------------------------
word = "kpia"
Returns: "NO"
-------------------------------------------------------
word = "chuchucpihu"
Returns: "NO"
-------------------------------------------------------
word = "pikapi"
Returns: "YES"
"pikapi" = "pi" + "ka" + "pi", so Pikachu can say it.
-------------------------------------------------------
word = "pipikachu"
Returns: "YES"
This time we have "pipikachu" = "pi" + "pi" + "ka" + "chu", so Pikachu can say it as well.
-------------------------------------------------------
word = "pikaqiu"
Returns: "NO"
Pikachu can't say "pikaqiu" since 'q' does not appear in "pi", "ka", or "chu".
-------------------------------------------------------
word = "chupikachupipichu"
Returns: "YES"
-------------------------------------------------------
word = "duke"
Returns: "NO"
In: Computer Science
IN C++
Note: While there are many ways to do conversions to pig latin, I will require that you follow the procedures below, all of which will use the following structure:
struct Word {
string english;
string piglatin;
};
Part 1. Write a function that takes in an English sentence as one string. This function should first calculate how many “words” are in the sentence (words being substrings separated by whitespace). It should then allocate a dynamic array of size equal to the number of words. The array contains Word structures (i.e. array of type Word). The function would then store each word of that sentence to the english field of the corresponding structure. The function should then return this array to the calling function using the return statement, along with the array size using a reference parameter.
This function should also remove all capitalization and special characters other than letters. Implement the function with the following prototype
Word * splitSentence(const string words, int &size);
Part 2. Write a function that takes in an array of Word structures and the size of the array and converts each english field to the corresponding piglatin field.
void convertToPigLatin(Word [] wordArr, int size);
To do this conversion, if a word starts with a consonant, the piglatin conversion of the word involves moving the first letter of the word to the end of the string and then adding “ay” to the end.
pig -> igpay
cat -> atcay
dog -> ogday
If the word starts with a vowel, simply add “way” to the end of the word
apple -> appleway
are -> areway
Part 3. Write a function that takes in an array of Word structures and outputs the pig latin part of it to the screen, with each word separated by a space.
void displayPigLatin(const Word [] wordArr, int size);
Example:
Please enter a string to convert to PigLatin: Casino is nothing but a Goodfellas knockoff Output: asinocay isway othingnay utbay away oodfellasgay nockoffkay
Error conditions: Your program should get rid of all punctuation and special characters other than letters. Your program should be able to deal with there being two or more spaces between words.
Note: Make sure to follow proper programming style, as per the style supplement.
In: Computer Science