//Normal Programs:
import java.util.*;
class AreaOfShapes
{
float a;
void areaOfReactangle(int l, int b)
{
a=l*b;
System.out.println("The Area of a Rectangle is " +a );
}
void areaOfTriangle(float ba, float h)
{
a=ba*h/2;
System.out.println("The Area of a Triangle is " +a );
}
void areaOfCirle(float r)
{
a=3.14f*r*r;
System.out.println("The Area of a Cirle is " +a );
}
public static void main()
{
AreaOfShapes ob=new AreaOfShapes();
float ba,h1,r1;
int l1, b1;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the Length of a Rectangle " );
l1=sc.nextInt();
System.out.print("Enter the Breadth of a Rectangle " );
b1=sc.nextInt();
ob.areaOfReactangle(l1,b1);
System.out.print("Enter the Base of a Triangle " );
ba=sc.nextFloat();
System.out.print("Enter the Height of a Triangle " );
h1=sc.nextFloat();
ob.areaOfTriangle(l1,b1);
System.out.print("Enter the Radius of a Cirle " );
r1=sc.nextFloat();
ob.areaOfCirle(r1);
}
}
//Method/Function Overloading
import java.util.*;
class MethodOverloading
{
float a;
void area(int l, int b)
{
a=l*b;
System.out.println("The Area of a Rectangle is " +a );
}
void area(float ba, float h)
{
a=ba*h/2;
System.out.println("The Area of a Triangle is " +a );
}
void area(float r)
{
a=3.14f*r*r;
System.out.println("The Area of a Cirle is " +a );
}
public static void main()
{
MethodOverloading ob=new MethodOverloading();
int l1, b1;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the Length of a Rectangle " );
l1=sc.nextInt();
System.out.print("Enter the Breadth of a Rectangle " );
b1=sc.nextInt();
ob.area(l1,b1);
System.out.print("Enter the Base of a Triangle " );
ba=sc.nextFloat();
System.out.print("Enter the Height of a Triangle " );
h1=sc.nextFloat();
ob.area(l1,b1);
System.out.print("Enter the Radius of a Circle " );
r1=sc.nextFloat();
ob.area(r1);
}
}