# Calculate the circumference of a circle

• 1
• Locked
Well, we have a plan. Let's implement it. First, implement a method that calculates the circumference of a circle. To do this, you need to write the correct formula in the method and specify the arguments. But what about pi, which we know is 3.141592... and so on to infinity? We'll keep things simple: let pi = 3.14.
You can't complete this task, because you're not signed in.
VandruGG Software Developer
28 September 2022, 21:26
The solution is simple. Have to create a variable to store the value of PI (this must be double type because PI is a floating number), then create a variable to use the formula. At the end, print the value of that variable on screen like all the past examples. Radius value is obtained from main method that is passed as parameter.
Anonymous #10829459
Level 2 , Spain
8 October 2021, 16:20
doble ... doble .. system c
Anonymous #10793745
Level 3 , Cincinnati, United States
17 September 2021, 11:51
Can someone please clarify why you must use "int radius" for the method and why it won't work with a double? I would assume that it would be the exact opposite, the instructions even say that the result should be a fractional double.
Dav
Level 2 , United States of America
23 October 2021, 14:36
I tried it on another compiler switching out double for int. It compiled fine. Also, stackoverflow mentions it is default. “ By default, Java uses double to represent its floating-point numerals (so a literal 3.14 is typed double). ” and the reqs just say it will be a “fractional number” that happens to be a “(double)”.
Sergio
Level 3 , Beaverton, Spain
30 December 2022, 07:07
MathBechy
Level 2
2 July 2021, 15:10
I love it!!!
Level 3 , Denver, United States
2 April 2021, 18:17
I did not have to declare any variables for it to pass... But what I am wondering is how the answer came out as a double, when only the data type int was used?
Java_Mooood
Level 3 , San Antonio, United States
12 October 2020, 20:00
declare 2 double variables in printCircleCircumference , pi and c print the c , second variable
Steven
Level 3 , United States
24 November 2020, 21:12
awesome :)
Velociraptor
Level 3 , Bangalore, India
23 July 2020, 09:28
This is not working the first condition is not satisfied
byron
Level 2 , Hammond, United States
17 May 2020, 08:41
Where do you all explain the lesson?
P S
Level 3 , United States
26 April 2020, 14:09
I'm a little mixed up myself. I got the same thing you did, but for some reason, it's not accepting my code. When I say System.out.print(C), i get 31.400000000000002, but when I say System.out.print(pi), I get 3.14. Am I doing something wrong?
P S
Level 3 , United States
28 April 2020, 13:57
And its also not working when I change the 'pi' value to .314. Can someone please help me?
Roman
Level 41
29 April 2020, 07:27
Please refer to Help section at our course.
lucascorrea Backend Developer at Compasso UOL
9 October 2021, 14:28
Hello, friend! You can use 'printf' instead of, thus, you can use decimal formatting like this:
``System.out.printf("%.2f", C);``
The return will be with only two decimal places.
Felix
Level 8 , Center Moriches, United States
24 December 2019, 07:01
I know my code is all out of wack but this generated a correct answer. Can anyone concur?