solution:_
1. Design a class prog_1 with the following details:
double area(int x): Return the area of a square.
double area(int x,int y): Return the area of a rectangle
double area (double y): Return the area of a circle
void main (): Invoke the overloaded function area() to find the area of square, rectangle, circle.
import java.util.*;
class prog_1
{
double area(int x)
{
double a= x*x;
return x;
}
double area(int x, int y)
{
double a= x*y;
return a;
}
double( double y)
{
double a = 22/7*y*y;
return a;
}
void main()
{
Scanner ob=new Scanner(System.in);
int p,q,s;
double r;
System.out.println("Enter the side of the square");
s=ob.nextInt();
System.out.println("Enter the length of the rectangle");
p=ob.nextInt();
System.out.println("Enter the breadth of the rectangle");
q=ob.nextInt();
System.out.println("Enter the radius of the circle");
r=ob.nextDouble();
System.out.println("The area of the square is"+area(s));
System.out.println("The area of the rectangle is"+area(p,q));
System.out.println("The area of the circle is"+area(r));
}
}