FileDocCategorySizeDatePackage
UsePI.javaAPI DocExample546Sat Sep 29 23:58:28 BST 2001None

UsePI.java

// Example of using the constant PI
//Uses c = 2 * pi * r to find circumference of a circle
import java.io.*;

class UsePI {
  public static void main (String [] args) {
    double storePI = Math.PI; // Pi is just a number
    double radius = 1.2;
    double circumference;
    circumference = 2 * storePI * radius * radius;
    System.out.println("The value of PI is " + storePI);
    System.out.print("The circle with radius " + radius);
    System.out.println("has circumference " + circumference);
  } // end main
} // end UsePI