Area of Circle in Java Using math.pi

Area of circle in java. This Java program will print the area circumference of a circle. The diameter of a circle is the distance around it in geometry. That is, the circumference is equal to the circle’s diameter. Pi times the radius of the circle squared is the area of a circle. The circumference of a circle is the distance around it in geometry. That is, the circumference is equal to the circle’s diameter. The radius of a circle squared is pi 3.14 times the area of the circle.

Float Value in Java Program

The float keyword in Java refers to a primitive data type. It’s a 32-bit IEEE 754 floating-point with single precision. It’s where variables and methods are declared. It is used to represent fractional numbers.

Float and Double Value in Java

Both the Double and the Float are used to represent decimal numbers, albeit in slightly different ways. When you multiply pi by 1000, both Double and Float sacrifice some precision after the comma. This means that Float has just four decimal places, but Double has twelve.

How to Calculate Area and Circumference of Circle

It’s as simple as this: C = d. The circumference of the circle is represented by “C,” and the diameter is represented by “d.” That is, multiplying the diameter by pi will give you the circumference of a circle.

``````import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
float r;
double area, circumstances;
Scanner scan = new Scanner(System.in);
System.out.print("Enter Radius of Circle ");
r = scan.nextFloat();
area = 3.14*r*r;
circumstances = 2*3.14*r;
System.out.print("Area of Circle = " +area);
System.out.print("\nCircumstance is " +circumstances);
}
}``````

Output:

Enter Radius of Circle 5

Area of Circle = 78.5

Circumstance is = 31.400000000000002