Question: [JAVA PROGRAMMING LANGUAGE] CODE: public static class Area { public static double getArea(double radius) { return Math.PI * radius * radius; } public static double
[JAVA PROGRAMMING LANGUAGE]
![[JAVA PROGRAMMING LANGUAGE] CODE: public static class Area { public static double](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4654f2f803_75066f4654e9df8f.jpg)
CODE:
public static class Area {
public static double getArea(double radius) { return Math.PI * radius * radius; }
public static double getArea(int length, int width) { return length * width; }
public static double getArea(double radius, double height) { return Math.PI * radius * radius * height; } } Main program
public static void main(String[] args) {
// Area of a circle System.out.printf("The area of a circle with a " + "radius of 10.0 is %6.2f ", Area.getArea(10.0));
// Area of a rectangle System.out.printf("The area of a rectangle with a " + "length of 15 and a width of 25 is %6.2f ", Area.getArea(15, 25));
// Area of cylinder System.out.printf("The area of a cylinder with a " + "radius of 12.0 and a height " + "of 17.0 is %6.2f ", Area.getArea(12.0, 17.0)); }
ERROR:

WORK AREA Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes: circles -- area = n*radius^2 (format the answer to have two decimal places) rectangles -- area = width * length trapezoid -- area = (basel + base2) * height/2 Because the three methods are to be overloaded, they should each have the same name, but different parameters (for example, the method to be used with circles should only take one parameter, the radius of the circle). Demonstrate the methods in a program that prints out the following areas, each on a separate line: the area of a circle with radius 3 the area of a rectangle with length 2 and width 4 the area of a trapezoid with base lengths 3 and 5 and height 5 SAMPLE RUN #0: java Area Interactive Session Hide Invisibles Highlight: None Show Highlighted Only O 28.27- 8.00 17.5. COMPILER ERROR MESSAGES Print Content Ask My Results Support Instructor Area.java:18: error: class, interface, or enum expected Main program Area.java:20: error: class, interface, or enum expected public static void main(String[] args) { Area.java:27: error: class, interface, or enum expected System.out.printf ("The area of a rectangle with a " Area.java:32: error: class, interface, or enum expected System.out.printf("The area of a cylinder with a Area.java:35: error: class, interface, or enum expected } 5 errors 1 public static class Area { 2 3 4 public static double getArea ( double radius) { 5 return Math.PI * radius w radius; 6 } 7 8 9 public static double getArea(int length, int width) { 10 return length + width; 11 } 12 13 14 public static double getArea(double radius, double height) { 15 return Math.PI * radius + radius * height; 16 } 17 ) 18 Main program 19 20 public static void main(String[] args) { 21 22 1/ Area of a circle 23 System.out.printf("The area of a circle with a " 24 + "radius of 10.0 is 86.2f ", Area.getArea(10.0)); 25 26 // Area of a rectangle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
