Program Assignment #3 C.S.1428.751 Due: Tuesday, July 22, 2014 Develop an algorithm using top-down design and step-wise refinement to solve the problem listed below. Then implement your algorithm in C++. For this assignment you may work alone or with other students in your section to write a program to satisfy the following specifications (no more than three in a group). Names of all members of your group should be listed in the documentation at the top of the program as well as in the personal information section written as output. Turn in one paper copy per group on the due date. All members of your group must individually submit an electronic copy of the final project. Be sure all group members submit the same code under the same file name, or no credit will be given. Write a complete interactive C++ program that displays the following menu: Geometry Calculator 1. Calculate the surface area of a cube. 2. Calculate the surface area of a sphere. 3. Calculate the surface area of a cylinder. 4. Calculate the surface area of a rectangular prism. 5. Quit Enter your choice ( 1 - 5 ): If the user enters 1, the program should leave two blank lines before prompting for the length of one side of a cube. The program should leave two blank lines before displaying the length and the calculated surface area of the cube to the console. surface area of a cube = 6a2, where a is the length of the side of each edge of the cube If the user enters 2, the program should leave two blank lines before prompting for the radius of a sphere. The program should leave two blank lines before displaying the radius and the calculated surface area of the sphere to the console. surface area of a sphere = 4PIr2, where r is the radius of the sphere If the user enters 3, the program should leave two blank lines before prompting for the radius of the base of a cylinder and for the height of the cylinder. (Use two separate prompts. Leave one blank line between prompts.) The program should leave two blank lines before displaying the radius, height and calculated surface area of the cylinder to the console. surface area of a cylinder = 2PIr2 + 2PIrh, where r is the radius of the base of the cylinder & h is the height of the cylinder. If the user enters 4, the program should leave two blank lines before prompting for the lengths of the three sides of a rectangular prism. (Use three separate prompts. Leave one blank line between prompts.) The program should leave two blank lines before displaying the three input values and the calculated surface area of the rectangular prism to the console. surface area of a rectangular prism = 2ab + 2bc + 2ac, where a, b, and c are lengths of the 3 sides If the user enters the MAX_CHOICE, the program should end by displaying an appropriate message to the console. Notes: With the exception of the menu choices, all input data are real (in inches). Do not rearrange the order of operands in any of the formulas, or points will be deducted. Do not use single letter variable names in formulas. Use 3.14159 for the value of PI. You must use the pow function in the cmath library for calculations involving exponentiation. Use a named constant to represent the maximum menu choice to allow expansion of the menu options. The author's identifying information is displayed on the first three lines of the console followed by two blank lines and the display of the geometric calculator menu. Two blank lines are left before the first prompt in each case and again before any output message displayed on the screen. All output values for choices 1-4 must be appropriately labeled either by using descriptive terms or by including them in complete sentence form. Format calculated results to two decimal places. Do not use functions other than main, arrays, structures or classes to solve this problem. Assume intelligent, non-vindictive users. Neatness and readability will be taken into account when your console output is graded. Input validation: Display an appropriate error message to the console if the user enters a number outside the range of 1 - MAX_CHOICE when selecting an item from the menu OR if the user fails to enter a value greater than zero for the requested input values (length(s), radius, height.) In the event that erroneous input is entered (no loops allowed…yet), the program should end after the message appropriate to the situation is displayed to the console. This should result in a ‘normal’ exit. The problem is not with the program, it’s with the user entering erroneous input! Limit error checking to those situations mentioned above. Leave two blank lines before and after the error messages displayed to the console. Think carefully about what control constructs would be most appropriate to use. For example, should you use a multi-way branch for the menu, or would a switch work? Consider using the OR operator whenever possible. These are some things to think about before you start coding. Hint: For full credit, use a switch. Why? Note: The algorithm above is written so that one and only one return statement is used to exit this program. Significant points will be deducted if more than one exit is used since you will not have processed the algorithm as required to obtain full credit. Be prepared to run your program on any given data. The input choices will be available no later than Monday, July 22. You should test your program for each possible scenario before the release of the actual input values, since your program will be thoroughly tested by the grader. For full credit, you must process as follows. (See output sample for spacing/alignment, etc.) Display the author’s identifying information on the screen. See sample output screen for details. Display the Geometry Calculator menu on the screen. See sample output screen details. If the user enters an invalid menu choice, o Display an appropriate message to the console informing the user that an invalid menu choice was entered and that the program will terminate. otherwise, // valid menu choice is entered o Use a switch to: (Why would a switch be better than a multi-way branch?) When the user enters 1 o the program should prompt the user for the length of one side of a cube. o If the user enters a value of zero or less for the length of one side, the program should echo the input to the console, inform the user that the input was invalid, and let him/her know the program will terminate; o otherwise, the program should display the length of one side of the cube and the calculated surface area of the cube. Note: surface area of a cube = 6a2, where a is the length of the side of each edge of the cube. When the user enters 2, o the program should prompt for the radius of a sphere. o If the user enters a value of zero or less for the radius, the program should echo the input to the console, inform the user that the input was invalid, and let him/her know the program will terminate; o otherwise, the program should display the radius and the calculated surface area of the sphere. Note: surface area of a sphere = 4PIr2, where r is the radius of the sphere. When the user enters 3, o the program should prompt the user for the radius of the base of a cylinder o If the user enters a value of zero or less for the radius of the cylinder’s base, the program should echo the input to the console, inform the user that the input was invalid, and let him/her know the program will terminate; o Otherwise, the program should prompt the user for the height of the cylinder (in inches.) If the user enters a value of zero or less for the height of the cylinder, the program should echo the input to the console, inform the user that the input was invalid, and let him/her know the program will terminate; Otherwise, The program should display the radius, height and calculated surface area of the cylinder.to the console in sentence form. Note: surface area of a cylinder = 2PIr2 + 2PIrh, where r is the radius of the base of the cylinder & h is the height of the cylinder. When the user enters 4, o the program should prompt for the lengths of the three sides of a rectangular prism using three different prompts. o If the user enters a value of zero or less for the first side or for the second side or for the third side, the program should echo the input to the console, inform the user that the input was invalid, and let him/her know the program will terminate; o otherwise, the program should display the three input values and the calculated surface area of the rectangular prism. Note: surface area of a rectangular prism = 2ab + 2bc + 2ac, where a, b, and c are the lengths of the three sides. When the user decides to ‘quit’ and not use the Geometric Calculator, o the program should end by displaying an appropriate message to the screen. Using Eclipse-C++, create the source code in a file named prog3_xxxxxx.cpp, replacing xxxxxx with your Texas State NetID, also known as your account number, your username, your UIC, and your user identification code. Your NetID is made up of your initials followed by a series of digits. Make note of the case of the characters in the filename. e.g. I would name my file prog3_br02.cpp, since br02 is my NetID. If you work with others, the naming scheme must include all accounts. e.g. If Sally Student (ss0000) and I worked together, we would name our file prog3_br02_ss0000.cpp. (If groups fail to include all TxStateNetIDs in the filename and include all names authoring the code in documentation and program output, no credit will be given.) By default, Eclipse includes a partial documentation block at the top of each new source file created. To receive full credit for this assignment, you must replace the partial documentation block provided by Eclipse with complete program documentation. For this assignment, the complete documentation is provided for you. It is located in prog3_xxxxxx.cpp on the assignments page. Copy the content of prog3_xxxxxx.cpp into the file you just created replacing the partial documentation block generated by Eclipse. You are responsible for filling in any missing information provided in the documentation template. Pay special attention to this documentation which is much like that found in the example programs located on the assignments page (‘Hello World’ and the ‘Age Calculation’ programs). You will be required to include such documentation in all future programs. Print the source code from within Eclipse-C++ by following the instructions described in the Eclipse-C++ Compiler document under the C.S.1428 Support Materials link on your instructor’s web page, or no credit will be given. Print on the equivalent of the CS_Letter laser printer (single-sided, no holes), or points will be deducted. Print the console output from within WordPad by following the instructions described in the Eclipse-C++ Compiler document under the C.S.1428 Support Materials link on your instructor’s web page, or no credit will be given. Print a copy of the input values from the assignments page while viewing in your favorite browser, or no credit will be given. (The web address of this page must appear in either the header or the footer.) Turn in the source code, a copy of the input values, and a copy of the console screen output stapled in the top left corner (in this order). Legibly print by hand your full name and section number in the top left corner of the source code. Don't forget to electronically submit your program as well. Submit only prog3_xxxxxx.cpp. (Go to (Go to https://hwupload.cs.txstate.edu/ to submit.) to submit.) Do not submit .exe files, .o files, .out files or .rtf files. No credit will be given unless: the paper copies and the electronic copies are simultaneously available to the grader. the paper copies match the electronic copies. all files necessary for the grader to run your program are simultaneously available, which, in this case, means prog3_xxxxxx.cpp. Refer to my programming style guide, lecture outlines and your lecture notes for more programming requirements to include. Example output console prior to the user entering a menu choice. Pay special attention to horizontal and vertical spacing requirements not only in your source code but in the resulting screen display as well. Note detailed instructions above.