import java.io.*;

class filedemo1

{

public static void main(String as[])

{

double r;

DataInputStream dis;

try

{

dis=new DataInputStream(System.in);

do

{

System.out.println("enter radius:");

String rad=dis.readLine();

r=Double.parseDouble(rad);

if(r>0.0)

{

double ac=3.142*r*r;

double cc=2*3.142*r;

System.out.println("area of circle:"+ac);

System.out.println("circum of circle:"+cc);

break;

}

System.out.println("given number is negative so try again:");

}

while(r<0.0);

}

catch(NumberFormatException e1)

{

System.out.println("invalid number");

}

catch(Exception e2)

{

System.out.println("error");

}

}

}

 

 

Output:

E:\sycs_22_23\java>javac filedemo1.java

Note: filedemo1.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

E:\sycs_22_23\java>java filedemo1

enter radius:

2.5

area of circle:19.6375

circum of circle:15.709999999999999

E:\sycs_22_23\java>java filedemo1

enter radius:

-41

given number is negative so try again:

enter radius:

10

area of circle:314.2

circum of circle:62.839999999999996