Question
Write a program to calculate the area of two geometric shapes: triangles and circles. You must use functions. Here are the functions you should create:
Write a program to calculate the area of two geometric shapes: triangles and circles. You must use functions. Here are the functions you should create: public static double area_triangle( int base, int height ) // returns the area of a triangle public static double area_circle( int radius ) // returns the area of a circle Your program should present a menu (triangle or circle) for the user to choose which shape to calculate, then ask them for the appropriate values (length, width, radius, etc.). Then it should pass those values to the appropriate function and display the resulting area. Notice that you must not input the values inside the functions, and you must not display the values inside the functions. All input and output must be in the main(), and values must be passed to the functions and returned from them. You'll need the value of for area_circle(); feel free to use the built-in double variable called Math.PI.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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