HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
1. Feel Free to ask and submit anything on and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.

corejava-programming: Find area of a circle

Arjit wants to create a wall bisecting a circular ground. Write a program which takes the area of the ground in sq. units as input and gives the length of the wall(diameter) as the output. Find the diameter of the circle for any given area till 4 decimal places. Sample Input: 50.23 Sample Output: 7.9992 Hint: To find square root use Math.sqrt() and 3.14 as value of Pi. For rounding it upto 4 decimal places make use of DecimalFormat class of java.text package. Sample double d=123.456546; DecimalFormat f=new DecimalFormat("##.####"); System.out.println(f.format(d));

corejava x 351
programming x 167
Posted On : 2016-10-02 12:16:37.0
profile Aarti Kumar - Aarti Kumar


Check this code and let me know if conditions are satisfied or not.

import java.text.DecimalFormat;
import java.util.Scanner;
class AreaOfCircle
public static void main(String args[])
DecimalFormat f=new DecimalFormat("##.####");
Scanner s=new Scanner(;
double r=s.nextDouble();
double pi=3.14;
double dm=2*Math.sqrt(r/3.14);

Posted On : 2016-10-03 10:40:58
Satisfied : 2 Yes  0 No
profile Sudheer Kumar Javvadi - Sudheer Kumar Javvadi
Reply This Thread
I think i forgot to comment line number 10 i.e., double pi=3.14.
please comment or use Math.sqrt(r/pi) in line number 11.
profile Sudheer Kumar Javvadi - Sudheer Kumar Javvadi
0  96  0
Posted On :2016-10-04 00:10:27.0
Leave a Comment

Post Answer
Please Login First to Post Answer: Login login with facebook -