0
Primitive operators
During your math class, you are given a task to calculate the perimeter of a circle. You decide to write a small program that will take the radius as input, and will calculate and print the perimeter for you. The value for π (pi) is already defined. Sample Input 4 Sample Output 25.12 https://code.sololearn.com/ckpsyjMMHtmU/?ref=app
12 Answers
+ 9
//try this
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double pi = 3.14;
int radius = scanner.nextInt();
System.out.println(2*pi*radius);
}
}
+ 8
Perimeter of a circle means circumference.
C = 2πr
You need to declare radius as an input variable instead of giving direct values.
int radius=new Scanner(System.in).nextInt();
+ 2
Formula is 3.14*radius*2
Change the last line to System.out.println(area);
+ 2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double pi = 3.14;
double r=scanner.nextInt();
//your code goes here
double area=pi*r*r2
System.out.println (area);
}
}
//Modified your code just check
+ 1
import java. util.*;
public class Program
{
public static void main(String[] args) {
int radius=new Scanner(System.in).nextInt();
int area=3.14*radius*2;
System.out.println (area) ;
}
}
//Try this
+ 1
Somvardhan Shiva sorry I thought that you are checking for area as you have made a variable area
Formula is 2*3.14*r
0
Ask question only.
0
Ok
0
Ok, tell me what is the formula for finding the area of circle
0
Scanner scanner = new Scanner(System.in);
double pi = 3.14;
int radius = 4;
double area = 2*3.14*4;
//your code goes here
Systemy.out.println (area);
}
}
0
Sorry guys its not working
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double pi = 3.14;
int radius = scanner.nextInt();
System.out.println(2*pi*radius);
}
}
Good Luck