- 1
Code to print perimeter of circle
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 3.14; //your code goes here int radius = scanner.nextint(); int per= 2*pi*radius; System.out.println(per); } }
4 Respostas
+ 1
Phantom
No you can't convert double to int like that, you will get error. So cast with int like this:
int per = (int) (2 * pi * radius);
Btw in this practice result would be as double so assign calculation to a double variable.
0
Is there a way to convert double into integer
0
Yes through typecasting
0
Phantom make the per variable double