Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the question: Write a class that has three overloaded static methods for

ID: 3785506 • Letter: T

Question

This is the question:

Write a class that has three overloaded static methods for calculating the areas of the
following geometric shapes:

• circles -- area = *radius^2 (format the answer to have two decimal places)
• rectangles -- area = width * length
• trapezoid -- area = (base1 + 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

***Output required***

Code is not working...what is wrong with it...

import java.util.Scanner;

public class AreaDemo {

  
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("Please enter radius of circle");
double radius = scan.nextDouble();
System.out.println("Circle Area : "+Area.getArea(radius));
System.out.println("Please enter the width and length of Ractangle");
double width = scan.nextDouble();
double length = scan.nextDouble();
System.out.println("Ractangle Area : "+Area.getArea(width, length));
System.out.println("Please enter the base, length and height of trapezoid");
double cubWidth = scan.nextDouble();
double cubLength = scan.nextDouble();
double cubHeight = scan.nextDouble();
System.out.println("Cuboid Area : "+Area.getArea(cubWidth, cubLength, cubHeight));
  
  
}

}

Area.java

public class Area {
public static final double PI = 3.14;
public static double getArea(double radius){
return PI * radius * radius;
}
public static double getArea(double width, double length){
return width * length;
}
public static double getArea(double base, double length, double height){
return ((base + length) * height)/2;
}
}

Error Message:

Main.java:27: error: class, interface, or enum expected
Area.java
^
1 error

Run it in a different compiler I get these results if i remove the Area.java - strange

Circle Are: 28.2599999999

Rectangle Area: 8

Cuboid Area: 20

Explanation / Answer

Area class

Main program

Output

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote