Java - Calculate circle diameter, circumference and area of a circle

Description

Calculate circle diameter, circumference and area of a circle

Demo

package calculations;
import java.util.Scanner;


public class circleCalculation {

  public static void main(String[] args) {
    Scanner userInput = new Scanner (System.in);
    int circleRadius, circleDiameter;
    double circleCircumference, circleArea;
    final double pi = Math.PI;
    /*from  ww  w.ja  v  a  2 s  .  c o m*/
    System.out.println("Please enter the radius of a Circle: ");
    circleRadius = userInput.nextInt();
    
    circleDiameter = circleRadius * 2;
    circleCircumference = circleDiameter * pi;
    circleArea = pi * circleRadius * circleRadius;
    
    System.out.println("The diameter is : " + circleDiameter);
    System.out.println("The circumference is : " + circleCircumference);
    System.out.println("The area is : " + circleArea);
  }

}

Related Exercise