Due: Thursday, March 3, 2011, at noon, 100 points
For this assignment, you will submit multiple files containing a program written in C++. Remember, to electronically submit a program for this course, first change to the directory in which the file(s) resides and then type in, at prompt, the command:
cssubmit 53 section_letter assignment_number
Be sure that only the file(s) you want to submit are in that directory - make a directory for every assignment! The submit system runs just the same with multiple files. The submit system will deliver every .cpp and every .h file in the current directory to me. Name your files meaningful names and give them proper extensions.
Background: assignment #4
Specifications: You are to rewrite a solution to the core of assignment #4. But this time you are going to fully functionalize it, writing functions to do much of the work of that program so that the main function is very clean. It will be up to you to decide how to break up the program into component functions, and you will be graded on how well you do it. I would suggest you take one of two approaches (pseudocoded here):
begin main greet() loop menu() do_stuff() until quit chosen goodbyes() end main
In this first model, the switch-case to handle the menu choice is contained in the do_stuff() function. Each case would have function calls to handle the desired operations.
begin main greet() loop menu() switch (choice) until quit goodbyes() end main
In this second model, the switch-case to handle the menu choice is in main, and each case would contain function calls to handle the operations of the program. This is a little messier than the first, but it's simpler.
Of course, you would name your functions better than "do_stuff". (If you use "do_stuff", we're gonna do_stuff with your grade!) To further help you visualize what the code should look like, here's pseudocode for what I would expect to see under option 4:
if(number valid) if (assests_entered) aid=calc_aid(assests) else aid=calc_aid() print(aid) else error_message()
I think you can see the benefit to writing functions on how the program reads, especially if you name your functions properly. Be balanced in how you map out your functionalizing (a word I just made up). At any level, you don't want to have too many functions or too few functions. Use good judgement. Also, you are required to use the standard set of comments for each of your functions: i) a function description; ii) a precondition; and iii) a postcondition. These should be placed just above each function prototype. It is NOT necessary to put them with the function definitions.
A modification: The program requirements are to be modified in one way. The formulas for aid both contain the expression c * d * e * f * g. This is to be replaced with cd * max{e,f,g}. So, you will clearly need to formulate a function to calculate an exponential (one int raised to another int power), and another function to return the maximum of 3 ints sent to it. You are not to use the system file cmath for this functionality. Write your own. Note: The expression 00will be taken as 1 for this program1.
When you submit: Enter the following information
option 2
option 1, enter 1515153
option 2
option 4
option 1, enter 4040404
option 4
quit
As always, if you have questions, don't hesitate to ask your instructor or Nathan (in the lab Mon and Wed nights).
1The expression 00 is known as an "indeterminate form" and is not necessarily 1. It is possible for this to evaluate to any real number. You should learn all about it in calc II.