Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write a java code In this program, you will create an area calculator that can calculate the area of circles, triangles, rectangles, squares, and trapezoids,
write a java code 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 See the sample run below Sample Run The output below represents ONE execution. User inputs are labeled in red. Area Calculator Exit Circle Triangle Rectangle Square Trapezoid Please enter your option : Please enter the radius of the circle: The area of the circle is Area Calculator Exit Circle Triangle Rectangle Square Trapezoid Please enter your option : Please enter the base of the triangle: Please enter the height of the triangle: The area of the triangle is Area Calculator Exit Circle Triangle Rectangle Square Trapezoid Please enter your option : Please enter the width of the rectangle: Please enter the height of the rectangle: The area of the rectangle is Area Calculator Exit Circle Triangle Rectangle Square Trapezoid Please enter your option : Please enter the side of the square: The area of the square is Area Calculator Exit Circle Triangle Rectangle Square Trapezoid Please enter your option : Please enter the top of the trapezoid: Please enter the bottom of the trapezoid: Please enter the height of the trapezoid: The area of the trapezoid is Area Calculator Exit Circle Triangle Rectangle Square Trapezoid Please enter your option : Unknown option Please try again. Area Calculator Exit Circle Triangle Rectangle Square Trapezoid Please enter your option : Requirements 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