Computer Science, asked by hsvedant, 1 month ago

write a program to display the area and circumference of a circle using methods whose r is input by user at the time of calling a method​

Answers

Answered by adityapalaria
1

Answer:

Explanation:

Java Program to Calculate Area and Circumference of Circle

When the diameter is known:

Java Program to Calculate Area and Circumference of Circle

When the circumference is known:

Java Program to Calculate Area and Circumference of Circle

Where,

A: is an area of a circle

π: is a constant, whose value is 3.1415 or 22/7.

r: is the radius of a circle

d: is the diameter of a circle

C: is the circumference of a circle

Let's implement the above formulas in a Java program and find the area of the circle.

Answered by arnimaanuragmishra
0

Answer:

*

* @author: BeginnersBook.com

* @description: Program to calculate area and circumference of circle

* with user interaction. User will be prompt to enter the radius and

* the result will be calculated based on the provided radius value.

*/

import java.util.Scanner;

class CircleDemo

{

static Scanner sc = new Scanner(System.in);

public static void main(String args[])

{

System.out.print("Enter the radius: ");

/*We are storing the entered radius in double

* because a user can enter radius in decimals

*/

double radius = sc.nextDouble();

//Area = PI*radius*radius

double area = Math.PI * (radius * radius);

System.out.println("The area of circle is: " + area);

//Circumference = 2*PI*radius

double circumference= Math.PI * 2*radius;

System.out.println( "The circumference of the circle is:"+circumference) ;

}

Similar questions