What is wrong with this code receive error code tempfilejava
What is wrong with this code: receive error code:
temp/file.java:1: error: class, interface, or enum expected
 OverloadedMethods.java
 ^
 1 error
Compilation Failed
OverloadedMethods.java
 // OverloadedMethods class implementation
 public class OverloadedMethods
 {
 // area method with one parameter
 public static double area(double radius)
 {
 return Math.PI * radius * radius;
 }
   
   
 // area method with two parameters
 public static double area(double width, double length)
 {
 return width * length;
 }
   
   
 // area method with three parameters
 public static double area(double base1, double base2, double height)
 {
 return (base1 + base2) * height / 2.0;
 }
   
   
 // start main method
 public static void main(String[] args)
 {
 // call the overloaded methods and print their results
 System.out.printf(\"The area of a circle with radius 3 is %.1f\ \", area(3));
 System.out.printf(\"The area of a rectangle with length 2 and width 4 is %.1f\ \", area(2, 4));
 System.out.printf(\"The area of a trapezoid with base lengths 3 and 5 and height 5 is %.1f\ \", area(3, 5, 5));
 }
 } // end of class
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
Outpt results exspected
28.27
8.0
17.5
Solution
Hey Budyy.. You need to make an object of the class which later on can be used to call the methods defined in the class OverloadedMethods. The object should be made like
OverloadedMethod ob = new OverloadedMethod();
Use this ob to call the methods and pass the values like ob.area(3);


