Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a new Java project and make sure Create project from template is UNCHECKED ) . Use a meaningful name such as M 5 -
Create a new Java project and make sure "Create project from template" is UNCHECKED Use a meaningful name such as MPAAreaCalculator. Then create a new Java class called AreaCalculator in the src folder. Add a main method to this class. The program should follow the guidelines below.
In this program, you will create an area calculator that can calculate the area of circles, triangles, rectangles, squares, and trapezoids, given the correct input. This area calculator will depend on several methods that you need to create. Specifically, they are:
printOptions: this method prints out the title and menu options of the program. It does not require any arguments and does not return anything.
pi: this method does not require any argument and return a constant, not to the caller.
circle: this method requires a radius as its argument and will return the area of a circle based on the radius. This function must call the pi method you defined in the calculation.
triangle: this method requires two arguments: a base and a height. It will return the area of a triangle based on the arguments.
rectangle: this method requires two arguments: a width and a height. It will return the area of a rectangle based on the arguments.
square: this method requires one argument, a side, and it will return the area of a square based on the argument.
trapezoid: this method requires three arguments, a top, a bottom, and a height. It will return the area of a trapezoid based on the arguments.
Your program should keep running until the user enters
All methods mentioned above must be declared as public static
Valid options from users are from to where will terminate the program. The program should output an error message but continue running.
The program must repeat until the user ends it with being entered as the option.
Must use switch statement in main
Must call pi method in the circle method.
All numerical outputs must be exactly decimal places.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started