Java program to find the circumference of a circle

Java Programming Java8Object Oriented Programming

The circumference of a circle is double the product of its radius and the value of PI. Therefore, to calculate the circumference of a circle

  • Get the radius of the circle form the user.
  • Calculate the product
  • Print the final result.

Example

import java.util.Scanner;
public class CircumfrenceOfCircle {
   public static void main(String args[]){
      int radius;
      double circumference;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the radius of the circle ::");
      radius = sc.nextInt();
      circumference = Math.PI*2*radius;
      System.out.println("Circumference of the circle is ::"+circumference);
   }
}

Output

Enter the radius of the circle::
55
The circumference of the circle is::345.57519189487726


raja
Published on 26-Apr-2018 06:33:02
Advertisements