Computer Science, asked by pearl1030, 10 months ago


Write a program to find the circumference of a circle in java
(Hint:Circumference of circle=2*Pi*r, where Pi=3.14)​

Answers

Answered by naveli3
4

This is using scanner class

Attachments:
Answered by manas3379
10

Answer:

Without input :

class Circumference {

public static void main(String[ ] args) {

double r = 7;

double Circumference = 2 × 3.14 × r;

System.out.println("Circumference = "+Circumference);

}

}

With input :

1) Taking input as parameter:

class Circumference {

public static void main(double r) {

double Circumference = 2×3.14×r;

System.out.println("Circumference = "+Circumference);

}

}

2) Taking input through scanner:

import java.util.Scanner;

class Circumference {

public static void main(String[ ] args) {

System.out.print("Input radius : ");

double r = new Scanner(System.in).nextDouble();

double Circumference = 2×3.14×r;

System.out.println("Circumference = "+Circumference);

}

}

Hope it helps!

Mark me brainliest!

Similar questions