Question: JAVA: Design a Geometry class with the following methods: -A static method that accepts the radius of a circle and returns the area of the
JAVA: Design a Geometry class with the following methods:
-A static method that accepts the radius of a circle and returns the area of the circle.
Area = ? r2
-A static method that accepts the length and width of a rectangle and returns the area of the rectangle. Use the following formula:
Area = Length x Width
-A static method that accepts the length of a triangles base and the triangles height. The method should return the area of the triangle. Use the following formula:
Area = Base x Height x 0.5
The methods should display an error message if negative values are used for the circles radius, the rectangles length or width, or the triangles base or height.
Next, write a program to test the class, which displays the following menu and responds to the users selection:
Geometry Calculator
1. Calculate the Area of a Circle
2. Calculate the Area of a Rectangle
3. Calculate the Area of a Triangle
4. Quit
Enter your choice (1-4):
Display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu.
Create a service class and an application class.
In the service class:
-The service class includes a collection of frequently used math operations similar to the Math class in Java. All methods in the service are STATIC because they do not share data. There is NO NEED to declare private data members in the service class.
-If there is a constant used, you can declare it as a static constant outside methods in the data member declaration section in the service class.
-Each method RETURNS a value.
In the application class,
-Validate each input and allow the user to re-enter a value.
-Call static methods in the same way as calling Math methods.
-Format numeric values with two decimal points in outputs.
Please have it in javadocs comments

jGRASP Wedge2 Geometry Calculator . Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your cho ice (1-4) : 1 What is the circle's radius? 5.6 The circle' s rea is 98.52 Geometry Calculator . Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your cho ice (1-4) : 2 What is the rectanlge' s length? 5 What is the rectan ?ge's width? 9.5 The rectangle's area is 47.5 Geometry Calculator . Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your cho ice (1-4) : 3 What is the length of the triangle's base? 8 What is the triangle's height? 5.5 The triangle's area is 22 Geometry Calculator . Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your cho ice (1-4) : 4 Goodbye
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
