//area1.java
import java.io.*;
class area
{
int x;
double y;
void cal(double pi,int ra)
{
y = pi*ra*ra;
System.out.println("Circle area is\t:"+y);
}
void cal(int len)
{
x = len*len;
System.out.println("Squre area is\t:"+x);
}
void cal(int len,int br)
{
x = len*br;
System.out.println("Rectangle area is\t:"+x);
}
}
class area1
{
public static void main(String args[])throws IOException
{
DataInputStream in = new DataInputStream(System.in);
System.out.print("choose any one \t 1.CIRCLE \t 2.SQURE \t 3.RECTANGLE\t:");
int a = Integer.parseInt(in.readLine());
area A = new area();
if(a==1)
{
System.out.print("Enter the radius\t:");
int b = Integer.parseInt(in.readLine());
A.cal(3.14,b);
}
else if(a==2)
{
System.out.print("Enter the length\t:");
int c = Integer.parseInt(in.readLine());
A.cal(c);
}
else
{
System.out.print("Enter the length\t:");
int d = Integer.parseInt(in.readLine());
System.out.print("Enter the breath\t:");
int e = Integer.parseInt(in.readLine());
A.cal(d,e);
}
}
}
No comments:
Post a Comment