Write a program in java to enter the radius of a circle and to calculate its circumference.
Answers
Question:
Write a program in java to enter the radius of a circle and to calculate its circumference.
Answer:
import java.util.*;
public class Scanner
{
Scanner in =new Scanner(System.in);
float r,c;
System.out.println("Enter the radius of the circle");
r=in.nextFloat();
c=2*(22/7)*r;
System.out.println("The circumference of the circle is="+r);
}
}
Explanation:
We know that, the area of a circle is= 2πr
But in programming we can put 'π' directly so we should put the value of 'π' directly that is, 22/7.
Since the value of the radius and also of the area can be in decimal point so, we should input the values in float data type.
For more java programmings follow the given links as I have solved earlier:
brainly.in/question/14797688
brainly.in/question/16088835
https://brainly.in/question/16195333
Explanation:
open this image hope it helps you