Question: write a Java Program: using style 4 method, sample attached. Write a program that can calculate the area of four different geometric shapes: triangles, squares,

write a Java Program:
write a Java Program: using style 4 method, sample attached. Write a
using style 4 method, sample attached.
program that can calculate the area of four different geometric shapes: triangles,

Write a program that can calculate the area of four different geometric shapes: triangles, squares, rectangles, and circles. You must use four Style 4 methods in your program Your program should present the foliowing menu to the user to ask them what to calculate: 1. Triangle 2. Square 3. Rectangle 4. Circle 3. Quit Using a switch with 5 cases, ask the user to type in the appropriate values (length, width, radius, etc.) in the main method. For example, if the user chooses a triangle, they should only be asked to type in base and height. If the user chooses a circle, they should only be asked for the radius. The user should be allowed to enter decimal (double) numbers for all the shapes. As soon as you display the calculated area, they should automatically see the menu again where they can pick another shape to calculate. This chart contains the relevant area formulas: shape formula square A = orix rectangle A = {XW triangle Abh circle A = Note that you must not use the Scanners inside the methods, and you must not display (output) inside the methods. All input must be in the main method, and you must call the relevant method from inside each case. Area values must be returned from methods to be displayed from main Forn, feni free to use either 3.14, or the built-in Math.PI constant variable in your formula. Remember to include //comments at the end of each method and the entire program, a header for the program as well as a header for each method, including @saram and @return tags. Don't forget to error-trap for any unwanted input Sample output: 1) Sangie 2) Square 3) Rectangle 4) Circle 5) Quit Enter your choice from the menu: 1 Enter the banet 5.3 Enter the beske: 6.2 The area 16.43 Assessment - Unit 5 - Area Calculator Methods -- Style 4 (does receive arguments, does return values) returns an integer to main public static int name(int x) { method needs to receive an integer Style 4: Our fourth style of method takes arguments AND returns a value. 1/Demo Program for Methods public class method4test { public static void main(String[] args) { int test1 = 12, test2 = 10; // notice in this next line the method named "min" is in a print statement System.out.println("The minimum of " + test1 + " and " + test2 + "is" + min(test1, test2) + "."); } // Method to find minimum // This method needs to receive two integers and returns one integer. // Notice the names of the variables sent (testi, test2), // and the parameters receiving them (int x, int y) are not the same. public static int min(int x, int y) { int minimum; // local variable if (x

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!