Assignment 05

Due: Thursday, Feb. 23, 2012, 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 translater. 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?

Now, the above outline is just a suggestion (a good one too!), but you can design your code other ways also. But it good. You will be judged by the grader on how nice your code is busted up into functions.

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

* Note: No ions were harmed in the preparation of this web page. We made fun of Dr. Nick, but only his nonexistent feelings were hurt. We promise not to do it again.

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.