Ads

Ads

View Answers

October 4, 2008 at 11:47 AM

Hi friend,

I am sending running code. I hope, This code will help you.

import java.io.*;

public class RadiusCircleDemo{

public static void main(String[] args){

int r=0;

int s=0;

try{

BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

String str="y";

while(str.equals("Y")||str.equals("y")){

System.out.println("Enter Radius of Circle : ");

r = Integer.parseInt(buff.readLine());

double area = java.lang.Math.PI*r*r;

System.out.println("Area of Circle : "+area);

double perimeter =2*java.lang.Math.PI*r ;

System.out.println("Perimeter of Circle : "+perimeter);

System.out.println("Please enter number continue!");

s = Integer.parseInt(buff.readLine());

double area1 = java.lang.Math.PI*s*s;

System.out.println("Area of Circle : "+area1);

double perm =2*java.lang.Math.PI*s ;

System.out.println("Perimeter of Circle : "+perm);

System.out.print("would you like to Continue y or n:");

str=buff.readLine();

System.out.println("Good by");

}

}

catch(Exception e){

System.out.println("Error : "+e);

}

}

}

----------------------------------------------------------

Visit for more information.

http://www.roseindia.net/java/

Thanks.

Amardeep

I am sending running code. I hope, This code will help you.

import java.io.*;

public class RadiusCircleDemo{

public static void main(String[] args){

int r=0;

int s=0;

try{

BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

String str="y";

while(str.equals("Y")||str.equals("y")){

System.out.println("Enter Radius of Circle : ");

r = Integer.parseInt(buff.readLine());

double area = java.lang.Math.PI*r*r;

System.out.println("Area of Circle : "+area);

double perimeter =2*java.lang.Math.PI*r ;

System.out.println("Perimeter of Circle : "+perimeter);

System.out.println("Please enter number continue!");

s = Integer.parseInt(buff.readLine());

double area1 = java.lang.Math.PI*s*s;

System.out.println("Area of Circle : "+area1);

double perm =2*java.lang.Math.PI*s ;

System.out.println("Perimeter of Circle : "+perm);

System.out.print("would you like to Continue y or n:");

str=buff.readLine();

System.out.println("Good by");

}

}

catch(Exception e){

System.out.println("Error : "+e);

}

}

}

----------------------------------------------------------

Visit for more information.

http://www.roseindia.net/java/

Thanks.

Amardeep

Ads

Related Tutorials/Questions & Answers: