Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Programming Assignment 6: Menu-Driven Dictionary

COP 3363 - Spring Term 2022

Major Learning Objectives

    To write a program which requires the manipulation of an array of structs     To utilize subarray processing

    To utilize the C++ string class and some string class member functions     To implement a menu using string input and string matching                     To perform both a sort and a search on an array of structs

Problem Statement

Your task is to write a menu-driven dictionary program. The commands which you must handle are:

sort            Sort the dictionary into alphabetical order, by words .

lookup        Look up a word in the dictionary, and print its definition if it is found. If it is not found, print an appropriate  message .

dump          Print a table of the current dictionary contents. If the dictionary is empty, print a message to that effect.

exit             Exit the program.

You will need to sort the dictionary.  Use either the Selection Sort as covered in lectures, or the Bubble Sort as covered in the course textbook. You will need to search the dictionary for the    lookup command.  Use the linear search as this search needs to work whether the sort has been done, or not.

Set up your dictionary to handle up to a maximum of 25 words.

Input and Command Parameters

You will be provided with two data files in the class UNIX file space, dictionarydata.txt and       short.txt. The shorter file is helpful in your testing and debugging process early on.  The program should work correctly on both files.  Graders may test your program with additional files.

Your program must read in the file name from the user using interactive input, and then open the file after that input operation.

The first line of the file will contain the number of words in the file.  You may assume that this number is valid for the array size specified in this writeup.

After you have read in the number of words, your program must read all of the words and definitions and load them into the array of structs.

Once the data structure is loaded, you will use interactive commands to do the rest of the processing.

The dump and exit commands will have no parameters. All valid commands will be in only lowercase letters. Only the entire command as specified above is acceptable as valid.

A data line with the lookup command must in addition contain then read 1 parameter:  a word to lookup.

All words for input will be given in all lowercase letters, and will contain only alphabetic characters.

Error Checking

You are required to implement a check to see if the data file has opened successfully, and if it has not, your code must terminate the program with a descriptive error message. You can use either the return function and implement a second return in main (like the return                      (EXIT_FAILURE) shown in lecture 17), or you may use the exit function and exit from any  function in the program, as shown in the same lecture.

You may assume that the data file is completely valid.

Output

Your output must be clear and informative, telling the reader what the input is, and what your    program is doing for each command processed.  For any invalid command line, you do not have to echoprint the remainder of the line after the command.  After an invalid command, do be sure to ignore the remained of the input line.

Be sure to follow all of the course style guidelines provided to you for output.   Try asking         yourself this question - if you were reading the output yourself, what would you need, and want, to see for the output to be clear, readable and well formatted?

Use Of Functions, Parameters, Modularity, Design et. al.

Part of your grade on this project will be determined by how well you utilize multiple functions   and parameter passing appropriately and how well you design a modular and functionally             cohesive program using the principles discussed in class. Large grade point penalties will be        incurred for not setting up a modular, well designed program structure. Global variables must not be used or large point penalties will be applied. All of the above emphasizes good program          structure, design, and very basic, fundamental software engineering principles. Start by working  on a good design, structure chart, etc. Recitation meetings will be an excellent source of help       with this.

Use Of Data Structures and Data Types

You are required to use an array ofstructs as the major data structure on this project with each    struct as specified earlier in this write-up.  Use the C++ string class to store and process words    and definitions. Use the typedef construct to both create and work with your array of structs type. These are all project requirements.

You will only have one array of structs declared in this program.  You do not need any other      arrays to complete the task as specified (with the exception of the C++ string class objects          discussed above, which by nature, contain arrays as their class member data).  You may not use any two-dimensional arrays, dynamic arrays, or user-defined classes on this project.  You also   may not use the C++ Standard Template Library classes or algorithms, with the exception of the C++ string class as described here, and the standard basic iostream classes as discussed in this   course.  Do not create any classes on this project.

What File To Turn In, File Naming Requirements, and Turning In Your Work to Canvas

Turn in your single C++ program source file which must be named as follows.  Use this format: yourLastNameLowerCase_FSUID_p6.cpp

Your FSUID will be unique to you, will typically be your FSU email ID, and will be something like "ab23c." Hence file names will look something like "smith_ab23c_p6.cpp"

Submit your single C++ file (.cpp) to Canvas using the Submit button for this assignment.   Be sure to download the file from Canvas also after you submit it in order to verify that you submitted the correct program file to Canvas and that it was successfully received by           Canvas.  Do remember that not submitting the correct file will result in a zero score, so the verification step is critical.