Create a C++ (version 11) program using the REPL.IT platform that performs the functions necessary to analyse and create anagramsC++ Programming

Task 2: Problem Statement – Anagram Solver (25%)

 

Create a C++ (version 11) program using the REPL.IT platform that performs the functions necessary to analyse and create anagrams; we shall define and anagram as a word or phrase formed by rearranging the letters of another word (for example: ‘spar’ can be formed from ‘rasp’, ‘regal’ can be formed from ‘lager’, etc.); in fact, ‘lager’ (depending on your database of words) could be anagrams of alger, argle, glare, large and regal – while ‘alert’ could be an anagram of alter, artel, later, ratel and taler.

Once run, your program should present the user with a menu that displays the title “C++ Anagram Solver Challenge” and presents the user with a number of menu choices.  Once the menu has been shown, the user must be asked to make a selection by stating “Please enter a valid option (1 – 5 or 0 to quit): ”. 

Ensure you design your program so that when initially executed it presents the user with the following options; match the layout and output as closely as possible:

C++ Anagram Solver Challenge

 

  1. Enter a word or phrase (current word/phrase is: alert).
  2. Find an anagram of the word.
  3. Find the largest word containing (most of) these letters.
  4. Find all possible 3 letter words that are also anagrams.
  5. Find all possible 5 letter words that are also anagrams.

 

  1. Quit the program.

Time taken to complete the last function was: 0ms

 Please enter a valid option (1 – 5 or 0 to quit):

 

If the user enters any non-valid option, your program must issue the following error message: Unfortunately, ‘XX’ is not a valid option, please try again.

Ensure your program replaces XX (contained inside the two single quotes) with the invalid option entered. For example, it the user enters the letter “q”, the error message would be:

Unfortunately, ‘q’ is not a valid option, please try again.

Anagram Solver: Program Requirements

Design your program so that each menu option (illustrated above) calls a dedicated function; your function names must be: GetWord, FindAnagrams, LargestWordAvailable, FindAll3LetterAnagrams, FindAll5LetterAnagrams and QuitNow.  With the exception of the quit option, your program must repeatably (after each menu option has completed) return and present the user with the menu (including the title).  If the user enters a new word or phrase (e.g. used option 1 to change the default word (which must initially be: alert) then this new word is displayed (until changed again) as part of the menu option (see above).  If the user selects the quit option (e.g. 0) the associated function must display the message:

Are you sure (Y/N)?

Your program will only terminate if the user enters either: “Y”, “Yes” or “y”; after which your function must use the C++ instruction: ”exit(EXIT_SUCCESS);” to terminate.

 

If the user enters any other response the program should return back to the menu function and allow them to select any other valid option (as many times as they like).

 

In addition, you will be expected to implement a fairly accurate timer that can be used to report the time taken to process the users request. For example once the user has selected option 2 (find an anagram) the function will initialise a timer that will count the time taken for the program to return with a result; take a look at the results summary used by Google after entering a search term – when searching the term “anagrams” it reported that it found about 72,500,000 results in 0.42 seconds. Design your program so the time taken to process each request is shown as part of the menu (specifically on the line “Time taken to complete the last function was…”).

 

Anagram Solver: Function Requirements

Each of the anagram functions (i.e. FindAnagrams(), LargestWordAvailable) must be designed to accept one argument; that argument will contain the value of the current word/phrase (e.g. shown in menu option 1).  Each of the function names should be defined using the following signature as a template (obviously you will need to use the required/actual function name:

void FUNCTION_NAME(std::string originalString) 

 However, both the functions: FindAll3LetterAnagrams() and FindAll5LetterAnagrams() must be designed not to accept or return any data:

void FUNCTION_NAME(void) 

 

Depending on how you decide to design and code your program you will be expected to use the test data provided (there are two test files for you to use: Words_100_Testing.csv and Words_1K_Testing.csv).  The Words100 file contains 100 random words while the Words_1K file contains 1000 random words. You are advised to start testing your code on the 100 version before using the 1000 word test file.  Your program will be assessed using a much bigger dataset (around 75,000 words so it is important to ensure your code is optimised first to work, then for speed).  Once you are sure your functions are working it is strongly suggested that you try using the pre-submission assessment csv file (this file contains approx. 75,000 English words) to more fully test and highlight any potential issues with your algorithm, code and/or its performance.

Anagram Solver: Defining your Data Source

It is critical that you design your program so that the datafile being used to provide all words needs to only be updated in only one line.  To achieve this, you must implement the following statement as the first line of your program (after the requested and commented headers, see structuring your code for more information):

#define cDATAFILE "xxx.csv"

You will need to change xxx.csv to the name of the file you are using for testing

e.g. #define cDATAFILE "Words_100_Testing.csv" if you want to limit your current testing to only 100 words -or- #define cDATAFILE "Words_1K_Testing.csv" if you want to test your program using 1000 words. You will need to add (upload) any files that contain test words to the REPL.IT platform; this can be done quickly via the “add file” option located in the Files panel on the left of the code window.

In addition to any other anagrams that might exist - and to help you better (and more quickly) test your code we have added two specific test words you can use to check your code is working; these words are: lager and alert – both searches should identify other, associated results (e.g. regal, glare, alger, later).

 Once uploaded and use different copies of the CSV files in your program by simply referencing the filename; see sample code for an example  

Anagram Solver: Function Operations

GetWord() -  this function is defined so that it does not expect any arguments, however it does return a string datatype.  Its purpose is to allow the user to enter a new word which can then be use by the other functions.  The function must return the user’s specified word or phrase; this replacement word should then be shown to the user as part of the previously defined Menu operation (specifically as part of the output line “current word/phrase is…”); ensure the function is declared appropriately.

FindAnagrams() – this function must be defined so that it expects only one string and does not return a result (the function’s input value must be named “originalString”; see the template signature discussed under the function requirements section for more detail).  A locally defined variable (called localString) should also be declared and initialised so that it is a copy of the original input value. Using the data from an appropriate test file (e.g. Words_100_Testing.csv or Words_1K_Testing.csv, etc) this function is required to scan all available words and identify and display each word that is an anagram of the string provided; the system must not include the original string as an anagram of itself.  If provided with the string “Lager” it should display all correct anagrams (e.g. regal, glare, etc); the system should (in addition to the words) also count the number of results found – in this case 2 anagrams of Lager.  You are expected to display the results in an efficient, logical, clear and organised way.  When matching anagrams you are requested to ignore case; Lager and lager are the same – this means that your system should not differentiate whether a word contains upper of lower case characters.

LargestWordAvailable() – this function must be defined so that it expects only one string and does not return a result (the function’s input value must be named “originalString”; see the template signature discussed under the function requirements section for more detail).  A locally defined variable (called localString) should also be declared and initialised so that it is a copy of the original input value. Using the data from an appropriate test file (e.g. Words_100_Testing.csv or Words_1K_Testing.csv, etc) this function is required to scan all available words and identify and display only the largest word available that contains (in any order) as many of the letters provided as possible; in essence this function should be able to solve the random words used in the gameshow “countdown” or “8 out of 10 cats does countdown”.  An example might be the letters “eshpoiexd”, your function may find the valid word “episode” or “exposed” or “epoxies”; however, in addition to finding the largest word it should also provide an indication of how many other words could be found of the same length.

FindAll3LetterAnagrams() – this function must be designed so that is scans your specified data file and identifies all entries that are examples of three letter anagrams; each sequence of anagrams must be displayed together and a clear separation must exist if a new sequence of three letter anagrams are found.

FindAll5LetterAnagrams() – this function must be designed so that is scans your specified data file and identifies all entries that are examples of five-letter anagrams; each sequence of anagrams must be displayed together and a clear separation must exist if a new sequence of three-letter anagrams are found.

QuitNow() – this function does not expect or return any data and must be declared as void.  Its purpose is to allow the user to exit the program. Once selected it must allow the user to change their mind using an “are you sure” option.  It the user is sure then the program will quit; however, if the user enters anything other than “Y”, “y” or “Yes” the user will we returned back to the menu function and allowed to select another option.

Attachments:

Instructions Files

C++ Programming Experts

expert
Eric Bell
C++ Programming

88 Answers

expert
Dinh Hong P.
C++ Programming

20 Answers

View More Experts
Disclaimer

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.

Get Free Quote!

269 Experts Online