# Java Programming : Diameter and circumference of the circle

#### Example

```plaintext
Input 
enter the radius of the circle 5
Output 
The diameter of the circle is : 10 
The circumference of the circle is: 31.4
```

#### **Required to know**

Use of **Variables**, Use of different operators like **assignment or arithmetic operators**, Use of functions like **System.out.print(), and** Use of **Data types.**

#### Formula

```plaintext
diameter of the circle = radius of the circle * 2 
circumference of the circle = 2 * 3.14 * radius of the circle
```

#### Steps

* Take the radius as input from the circle.
    
* Use the formula to find the Diameter and circumference of the circle.
    
* Print the value of the Diameter and circumference of the circle.
    

#### Program

```java
import java.util.Scanner;

public class Circle {

    /**
     * This class calculates the diameter and circumference of a circle.
     */

    public static void main(String[] args) {

        // Create a Scanner object to read user input.
        Scanner sc = new Scanner(System.in);

        // Prompt the user to enter the radius of the circle.
        System.out.print("Enter the radius of the circle: ");
        double radius = sc.nextDouble();

        // Calculate the diameter of the circle.
        double diameter = 2 * radius;

        // Calculate the circumference of the circle.
        double circumference = 2 * Math.PI * radius;

        // Print the diameter and circumference of the circle.
        System.out.println("The diameter of the circle is " + diameter);
        System.out.println("The circumference of the circle is " + circumference);
    }
}
```
