# Program To Calculate The Diameter, Circumference and Area of a Circle

The program below is the answer to Deitel's Java How to Program (9th Edition) Chapter 2 Exercise 2.28.

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.
/**
*
* @Author: Aghatise Osazuwa
* Website: www.cscprogrammingtutorials.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);

System.out.println ("This Application \n");

System.out.print ("Enter The Value For The Radius of The Circle: ");

System.out.printf("\nThe diameter of the circle is %d\nThe circumference "
+ "of the circle is %f\nThe Area of the circle is %f\n",

}
}

Click here to see other answers to Java How to Program.