Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 6 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 15 Sep 2017 My Price 10.00

criterion for this assignment

write a program that reads a list of words from a file, outputting only those words that meet certain criteria.
The criterion for this assignment is that folding the word back upon itself yields another valid word. We will interpret folding a word back upon itself as meaning that the new word is formed by
taking the first letter of the original word, followed by last letter, followed by second letter, followed by penultimate letter and so on, until all the letters in the original word are included.
Shown below are some examples.

 

- cider > cried
- bowl > blowp
- reserve > perverse
- example > eexlapm (Note that eexlapm is not a word and thus should not be included in the output)

 

So if a word contains 8 characters, the letters for the new words will be taken in the following order:

 

1 2 3 4 5 6 7 8           >       1 8 2 7 3 6 4 5
p r e s e r v e                   p e r v e r s e

 

If the word has an odd number of characters, the middle character comes last.

 

Start with findWords.cpp and findWordsMain.cpp on the bottom of this page and make the following changes:

 

findWords.cpp

 

-    Add function string foldWord(string inString) that returns a folded version(as described above) of inString.
-    Add function void lookForFoldedWords(const vector& lexicon) which calls foldWord(string inString) to fold the word and then calls findWord() to
   check for its existence in the lexicon, printing the word only if it exists in the lexicon. The output should consist of the original word, followed by a colon, followed by the folded word (e.g. feigner:freeing).
  
findWordsMain.cpp

 

-   So that we can use different input files ("Enhanced North American Benchmark Lexicon.txt" is a big file and can take a long time to fully process.), we will
   employ a way to specify a different input file at run time." Enhanced North American Benchmark Lexicon.txt" will still be the default if no other file is specified. The way to do this is to declare main as
                                  
                                   int main(int argc, char *argv[])
                                  
   The parameter argc will contain the number of command-line arguments and argv is an array of c- strings, with the command itself being argv[0], the first command-line argument being argv[1], and so on. Write code so that if argc is more than 1 (that means that there is a command-line argument) the file to open will be argv[1], otherwise the file name will default to" Enhanced North American Benchmark Lexicon.txt".

 

   There is nothing in our text about command-line arguments, but if you do a web search for argc and argv, you will find lots of information. Here's a pretty good one:   http://web.eecs.utk.edu/~bvz/cs140/Notes/Argv/index.html
  
-    Call lookForFoldedWords() to display all the folded words that are themselves words.

 


Here are both files that need to be change.

 

findWords.cpp
________________________________________________
#include
#include
#include
#include
#include

 

using namespace std;

 

void loadLexicon(vector& lexicon, string fileName) {
   ifstream in;
   string word;
   in.open(fileName.c_str());
   if(in.fail()) {
       cerr << "Cannot open file " << fileName;
       exit(1);
   }
   in >>word;
   while (!in.eof()) {
       lexicon.push_back(word);
       in >> word;
   }
   }
bool findWord(string word, vector& lexicon) {

 

   for(unsigned int i=0; i        if(lexicon[i] == word)
           return true;
   return false;
}
___________________________________________

 

findWordsMain.cpp

 

___________________________________________
#include
#include
#include

 

using namespace std;

 

int main(int argc, char *argv[0]) {
  
   if (int i=0; i    vector lexicon;
   string word = "poodle";
   loadLexicon(lexicon, "Enhanced North American Benchmark Lexicon.txt" );

   if(findWord(word, lexicon))
       cout << word << " is a word.\n";
   else
       cout << word << " is NOT a word. \n";

Answers

(5)
Status NEW Posted 15 Sep 2017 03:09 PM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)