# Calculate The Diameter, Circumference and Area of a Circle in java

Question: Write an application that inputs from the user the radius of a circle as an integer and prints the circle’s diameter, circumference and area using the floating-point value 3.14159 for π. Use the techniques shown in Fig. 2.7. [Note: You may also use the predefined constant Math.PI for the value of π. Use the following formulas (r is the radius):

diameter = 2r
circumference = 2πr
area = πr2

Do not store the results of each calculation in a variable. Rather, specify each calculation as the value that will be output in a System.out.printf statement. The values produced by the circumference and area calculations are floating-point numbers. Such values can be output with the format specifier %f in a System.out.printf statement.

## Java program to find diameter, circumference and area of circle

``````/*
*       Filename:  Circle.java
*
*    Description:  Exercise 2.28 - Diameter, Circumference and Area of a Circle
*
*			@Author:  Bilal Tahir Khan Meo
*        	Website: https://codeblah.com
*
* =====================================================================================
*/
import java.util.Scanner;

public class Circle{
public static void main(String[] args){
Scanner input = new Scanner(System.in);

int r;

r = input.nextInt();

System.out.printf("Diameter = %d\nCircumference = %.2f\nArea = %.2f\n",
2 * r, 2 * Math.PI * r, Math.PI * r * r);
}
}
``````

## Calculate The Diameter, Circumference and Area of a Circle in java

``````/**
*
*		@Author:  Bilal Tahir Khan Meo
*        	Website: https://codeblah.com
*
* Exercise 2.28 - Diameter, Circumference and Area of a Circle
* This Program Calculates The Diameter, Circumference and Area of a Circle
*
*/

import java.util.Scanner;

public class Ex02_28 {
public static void main (String [] args) {

Scanner value = new Scanner (System.in);