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
3 Answers
+ 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>.
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.