write a program to input the radius of a circle and calculate its area
Share
write a program to input the radius of a circle and calculate its area
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Verified answer
Answer:
import java.util.*;
public class Circle
{
public static void main(String args [])
{
Scanner in=new Scanner(System.in);
float r,a;
System.out.println("Enter the radius of the circle");
r=in.nextFloat();
a=(22/7)*Math.pow(r,2);
System.out.println("The area is =" +a);
}
}
Explanation:
● The radius or the area may can be in decimal point so, we should accept the values in float data type.
● For a circle,
Area = pie.r^2.