Question: Write a Java program, called MethodOverload that contains 5 static methods called area0. Each of these methods will calculate the area of a user inputted

 Write a Java program, called MethodOverload that contains 5 static methods

Write a Java program, called MethodOverload that contains 5 static methods called area0. Each of these methods will calculate the area of a user inputted shape; they will take in different. parameters as below. They should all retum a double and calculate the area of the corresponding shape (formulas given): 1. area(int) Area of a Square = len 2. len is the length of a side. 2. area(int, int) Area of a Rectangle =wh. w is the width of a side and h is the height. 3. area(double, int) Area of an Triangle =(1/2)bh. b is the base and h is the height. 4. area(double) Area of a Circle = pi r2. r is the radius of the circle. 5. area(double, double) -> Area of an Ellipse = pi*a"b. a is (1/2) the length of the major axis and b is (1/2) the length of the minor axis. The major and minor axis will be given in the question. The main method should take in user input to determine what shape the area needs to be calculated for. Depending on the shape given the program should then take in the correct parameters from the user (see Example below). Each input will be given in the order given in the descriptions above. You should also have an output if a non valid shape was entered. use "Not a valid shape!" as this message. NOTE: you can use Math.PI to get the value of pi in Java, and Math.pow (x,y) can be used for x to the power of y. Example of 4 . "Rectangle 4 4" would determine that you are required to find the area of a rectangle with width and height 4. Input n x where n is a string representing the shape, x is the number to go with Sample Input Square 4 Output The area of a square with side of length 4 Sample Output Area: 16.0

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!