Due: Wednesday, Oct. 2, 2019, at noon, 100 points
For this assignment, you will submit a single C++ compilable file containing a program written in C++. Of course, you will submit in the usual (correct) way.
Background: Dr. Nick has been having second thoughts about the medical profession and all the seemingly necessary "accountabilities" and "high expectations" about "professionalism" and "doing things right!" and nonsense like that. So what if you goof once in a while?! So, he's looking into other ideas about life. I really don't have any idea where this train of thought is going, but we did need some background.
Specifications: Your program is to present the user with a main menu for a translator. This translator will have the user enter an alphabetic character and give options to convert it into Morse code, ASCII, or change its case (lower case to upper case, or vice versa). Of course, your menu of options should have a quit also. The menu should look like this:
TRANSLATE --------- 1. Enter a character (alphabetic) 2. Morse code equivalent 3. ASCII value 4. Change case 5. Kwit1
If you have any good ideas how this pertains to Dr. Nick, let me know please.
Details: The foremost detail for this assignment is that you are required to use functions for much of this code. This does not mean that you will write one or two functions. No, you will use many functions to simplify the overall coding landscape in your program. Here is a suggested main function in pseudocode:
begin main declare necessary variables greetings() do option = present_menu()
quit = option_handler(option,input,entered) while (!quit) goodbyes() end main function Clearly, the present_menu() function will present the menu of options and return an option that you will pass to the option_handler() function. That function will return a bool indicating quit/notquit. The option_handler() will act upon the option passed and should look something like this:
bool option_handler(char option, char alpha, bool option1_chosen) quit = false decide on (option) option is 1 alpha = get_input_from_user() option1 chosen is true option is 2 if option1_chosen output morse(alpha) else error_message() option is 3 if option1_chosen output ascii(alpha) else error_message() option is 4 .......you get the idea ......... option is 5 set quit flag return quit end option_handler function
There are some details here that we leave for you to figure out. Some things to think about:
how will the parameters be declared?
why do all those parameters have to be there in the first place?
what's the purpose of the if-statement under cases 1 - 3?
how do you write the functions get_input_from_user(), morse(), error_message(), ascii(), and possibly others?
Many of these questions can be answered by reading more! Here are some guidelines on how to construct the necessary functions:
The greetings() and goodbyes() functions return nothing, have no parameters, but simply output appropriate messages to the user of the program. (We think you can figure out which message by the descriptive function names we've used.)
The present_menu() function will return a character reflecting the user's menu choice, but has no parameters. The function will simply output the menu of options and prompt/read in the user's choice.
The option_handler() function will return true or false depending on whether the user has chosen to quit the program. It needs to be passed the character (option) that was chosen from the menu, needs to communicate back to its calling function the value of the alphabetic character the user enters for translation (think reference parameter), and it needs to know whether or not a character has indeed been entered for translation.
Optional: If you are bored with this program, do this: have option 2 read in a sentence and convert it to Morse code.
Remember: When writing your code, be sure to:
Use meaningful variable names.
Use proper spacing for indentations.
Use constant variable declarations where appropriate.
Include the comment block at the head of your file.
Comment code that needs it.
Be literate in your welcoming/signing-off messages and prompts and output.
Make the output pretty and user-friendly.
Note: Don't underestimate the time that it will take to write this program!
When you submit the submit script will compile and execute your program in the process. This means that you will be the "user" of the program for that few minutes. Now, in order that the grader isn't driven crazy by a multitude of inputs/outputs, you will ALL input the same values so that he has uniform output to grade. They are:
option 3
option 1, enter '5', then enter 'a'
option 2
option 3
option 1 and enter 'Z'
option 3
quit
As always, if you have questions, don't hesitate to ask your instructor or the LEAD tutors.
1Patented version of 'quit' manufactured by Szalapski-Soft Software Co., a new startup company specializing in options for menu options.