Answered step by step
Verified Expert Solution
Link Copied!

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, 3.14159(not 3.14), 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 0.(See the sample run below) Sample Run The output below represents ONE execution. User inputs are labeled in red. ********** Area Calculator **********0) Exit 1) Circle 2) Triangle 3) Rectangle 4) Square 5) Trapezoid Please enter your option (0-5): 1 Please enter the radius of the circle: 5.2 The area of the circle is 84.949.********** Area Calculator **********0) Exit 1) Circle 2) Triangle 3) Rectangle 4) Square 5) Trapezoid Please enter your option (0-5): 2 Please enter the base of the triangle: 10 Please enter the height of the triangle: 4.6 The area of the triangle is 23.000********** Area Calculator **********0) Exit 1) Circle 2) Triangle 3) Rectangle 4) Square 5) Trapezoid Please enter your option (0-5): 3 Please enter the width of the rectangle: 2.5 Please enter the height of the rectangle: 6.5 The area of the rectangle is 16.250********** Area Calculator **********0) Exit 1) Circle 2) Triangle 3) Rectangle 4) Square 5) Trapezoid Please enter your option (0-5): 4 Please enter the side of the square: 4.56789 The area of the square is 20.866********** Area Calculator **********0) Exit 1) Circle 2) Triangle 3) Rectangle 4) Square 5) Trapezoid Please enter your option (0-5): 5 Please enter the top of the trapezoid: 1.2 Please enter the bottom of the trapezoid: 3.4 Please enter the height of the trapezoid: 6 The area of the trapezoid is 13.800********** Area Calculator **********0) Exit 1) Circle 2) Triangle 3) Rectangle 4) Square 5) Trapezoid Please enter your option (0-5): 6 Unknown option 6. Please try again. ********** Area Calculator **********0) Exit 1) Circle 2) Triangle 3) Rectangle 4) Square 5) Trapezoid Please enter your option (0-5): 0 Requirements All methods mentioned above must be declared as public static ... Valid options from users are from 0 to 5, where 0 will terminate the program. The program should output an error message but continue running. The program must repeat until the user ends it with 0 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 3 decimal places.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt 1 7 4 .

Answered: 1 week ago

Question

=+16.10. 2.19 16.9 | Assume u(1) Answered: 1 week ago

Answered: 1 week ago

Question

1. Are my sources credible?

Answered: 1 week ago

Question

3. Are my sources accurate?

Answered: 1 week ago

Question

1. Is it a topic you are interested in and know something about?

Answered: 1 week ago