0

Calculating Perimeter of a circle | Java

I explained the problem in the code as a comment It says “ .class expected” https://code.sololearn.com/c9OjgMAmku8E/?ref=app

7th Dec 2020, 3:28 PM
hotto doggu
hotto doggu - avatar
3 ответов
+ 3
Are you supposed to get user input for <radius> variable? If so, then just go ahead and use the Scanner object to read a value for <radius>.
7th Dec 2020, 3:35 PM
Ipang
+ 2
Thank you so much guys, i got it thanks to you Simba Ipang
7th Dec 2020, 3:44 PM
hotto doggu
hotto doggu - avatar
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 3.14; //tu código va aquí //double <radius>=nexscanner double radius = scanner.nextDouble(); double per = 2*pi*radius; System.out.println(per); } } In my case y had problems because π is written pi in Java, first mistake. After that the thing was how to get the radius from the input the solution I tried first was scanner.nextInt(), that gave me a mistake because the results were in doubles, so I changed that to scanner.nextDouble() and finally it worked. Hope this could help someone.
18th Oct 2021, 11:34 AM
César Díaz Amat