Calculate The Circumference Of Circle Taking Radius From User | Java Programs

Output:

*** Circumference of Circle ***

Enter The Radius of Circle: 25
Circumference of Circle is: 157.07963267948

Click Here For Java Online Compiler

Solution:

import java.util.Scanner;

class CircumferenceOfCircle {

    static void circumference(int radius) {
        double cir = 2 * Math.PI * radius;
        System.out.println("Circumference of Circle is: " + cir);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("*** Circumference of Circle ***" + "\n");
        System.out.print("Enter The Radius of Circle: ");
        int radius = scanner.nextInt();
        circumference(radius);  //call circumference method 
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon