Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITTEN IN C++ One function = one job Reading an Input File What if the input file is empty or too big to fit into

WRITTEN IN C++

One function = one job

Reading an Input File

What if the input file is empty or too big to fit into your arrays? Let the user know. Use peek() function to check if a file is empty.

Watch for array boundaries and eof; C++ would not do it for you

Menu

Use a switch statement to implement the menu

Make sure your program can handle an input of a wrong data type; use cin.clear(); cin.ignore(numeric_limits::max(), ' ');

A user should be able to run the menu as many times as user wants

Output Formatting

output must be well-formatted, and easily understandable to those who have not seen the code

clearly label the output

Include test runs/ output as comment /* */ below all function definitions at the very bottom of the file with main()

MAIN INSTRUCTIONS

Using a switch statement, write a menu so that when a user chooses a menu option, it prints a message about what that menu option will do. I suggest using numbers as menu choices rather than letters. If you are familiar with enums, use enums for menu implementation. Test all menu options. Make sure to test for invalid input such as text entries and numbers that are not part of the menu available menu options. Let your program naturally stop by going to the end of main() when a user wants to quit. Do not use exit or return when a user wants to quit. Once it works, add more functionality (next step)

Put the menu into a loop and make sure a user can run the menu as many times as the user wants. Test it again.

Replace output statements in the menu with function calls. In other words, write a short function for each menu option to notify a user of what the menu option does. Test each menu option and make sure a user can run the program as many times as the user wants. Do not forget to test for invalid input.

You have created a "skeleton" for your program.

Write a function to read from a file (let's call it here getData()) into a temp string and print the temp on the screen as you read them (for now to ensure that words are read correctly). Keep track of the number of words read from the file. Call this function from the appropriate menu option. Test the function. Check the output on the screen against the entries in the input file. Did you get them all? Did it print the last entry? Did the last entry got printed twice? Keep in mind that a file may be empty or has more entries than your array can fit. Let's be nice to our users and tell them if we could not fit all entries into the array. Test it. If getData() works add more functionality by storing the text entries in an array of strings.

Modify getData(). If a text entry is longer than 3 characters ( use strlen() ), store it in the array of strings and print it to ensure that validation works. Add functionality to keep track of the words stored in the array of strings and the word discarded. Check against the input file. Test getData() by adding and removing words from the input file.

When getData() works, write a function to print an array (let's call it here print()). Call the function in the appropriate menu option. Test it. Off to the next menu option.

Write a function to print stats.

Quit option - not much to do here except for letting the user know that the program will quit.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago