Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS IN C++ Using a switch statement, write a menu so that when a user chooses a menu option, it prints a message about

THIS IS IN C++

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.

In the next lab, you will add more functionality and menu option. Keep testing each menu choice as you add them

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

Step: 3

blur-text-image

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

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions