
How to create Java Program to find a perimeter of circle using Radius
How to create Java Program To Find a perimeter of circle using Radius. Hello Guys Today I am going to show you How can we create a java program to find a perimeter of a circle using perimeter which is given to us.

Follow the Given Steps
- import the Scanner Class from java,util package
For Example
import java.util.Scanner;
- Create A Class And a main function
- And Create A Scanner Object
- Create 2 variables double type to store radius and perimeter (how to create a scanner object?)
For Example
import java.util.Scanner;
public class Perimeter{
public static void main(String[] args) {
double perimeter,radius;
Scanner obj=new Scanner(System.in);
System.out.println("Enter Circle Radius");
radius=obj.nextDouble();
perimeter=2*Math.PI*radius;
System.out.println("Perimeter Of Circle Is "+perimeter);
}
}
Output
Enter Circle Radius
- 10
Perimeter Of Circle Is 62.83185307179586
How to create Java Program to find a perimeter of circle using Radius : Another example and method.
In Java, computing the perimeter (circumference) of a circle based on its radius is straightforward. You can utilize the formula (2 \times \pi \times \text{radius}), where (\pi) is a constant value approximately equal to 3.14159. To implement this in a Java program, begin by importing the necessary classes. Then, prompt the user to input the radius using the Scanner class. Next, calculate the perimeter using the formula mentioned earlier. Finally, display the result to the user. Here’s a step-by-step breakdown:
- Import Classes: Import the Scanner class from the java.util package to facilitate user input.
- User Input: Prompt the user to enter the radius of the circle. Read this input using the Scanner class and store it in a variable.
- Perimeter Calculation: Compute the perimeter of the circle using the formula (2 \times \pi \times \text{radius}).
- Display Output: Print the calculated perimeter to the console, providing the user with the result.
Below is a sample Java program implementing these steps:
import java.util.Scanner;
public class CirclePerimeterCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the radius of the circle: ");
double radius = scanner.nextDouble();
double perimeter = 2 * Math.PI * radius;
System.out.println("The perimeter of the circle is: " + perimeter);
scanner.close();
}
}
By following this guide, you can create a Java program to efficiently calculate the perimeter of a circle based on user-provided radius input.
I hope It Helps You.