Overview
In a class named App, develop a menu-driven, console program for calculating the area of some standard geometric shapes.
Processing
Your program must perform the following processing:
Display this menu of processing options
Shape Menu 1 - Circle 2 - Rectangle 3 - Triangle 4 - Author information 5 - Exit Enter selection:
Read the user's menu selection
Use a switch statement to process the user's choice. The requirements for each selection are as follows:
Circle - When the user selects this item, prompt for and read the radius of the circle as a real number. If the value entered is greater than zero, calculate and display the area of the circle to two decimal places. Otherwise, display an appropriate error message and allow them to re-enter the radius until they enter a valid value. The formula you will need is
Area = pR2
where the value of p is readily obtained by coding: Math.PI
Rectangle - When the user selects this item, prompt for and read the length and width of the rectangle as real numbers. If the values entered are greater than zero, calculate and display the area of the rectangle to two decimal places. Otherwise, display an appropriate error message and allow them to re-enter the data until they enter valid values. The formula you will need is
Area = LW
Triangle - When the user selects this item, prompt for and read the base and height of the triangle as real numbers. If the values entered are greater than zero, calculate and display the area of the triangle to two decimal places. Otherwise, display an appropriate error message and allow them to re-enter the data until they enter valid values. The formula you will need is
Area = BH/2
Author information - When the user selects this item, simply display your name in a format of your choice.
Exit - When the user selects this item, display an appropriate termination message in a format of your choice. The program should then end.
If any other selection is made, display an appropriate error message.
If the user hasn't chosen to exit, repeat steps 1 through 3
Miscellaneous
Use my Keyboard class to read input data from the keyboard.
To help format the output for the desired number of decimal places, use the fixedFormat() method of my Utility class that accepts two parameters. Other class methods can be used to skip lines, draw a separator line, wait for the user to press the ENTER key, etc. For more information, see my Utility class.
You have a great deal of freedom in certain areas of this program. Be creative, but make the program easy to run. For some ideas, review my Sample 01 program.
Grading criteria
Your program will be worth 30 points to be awarded as follows:
Accuracy (20 points). The program should correctly perform all specified processing.
Creativity (5 points). The program should be original yet simple in design.
Maintainability (5 points). The program should contain useful comments, meaningful identifiers, and be logically structured. It should include an opening documentation block with your name and a brief description of what the program does. It should also have a block of comments in front of every major section of code (loops, decisions, cases, etc.).
Submission
E-mail me the contents of your App.java source file no later than midnight on the program due date. If you are using JBuilder 4 and the Test project previously copied from the College of Business network, this file will be in the src folder of the project. In the College of Business labs, the complete path of your source file is:
D:\Test\src\App.java
To verify that you are doing this properly, e-mail to yourself, copy the source code to your test project, and re-test the program. If it works for you, it will probably work for me.
Upon receipt of your project, I will send you a verification message. When your project has been graded, you will receive an e-mail with your project score and comments (based on the above criteria). All project scores will be posted on the Internet within a few days after the due date.