Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. public class Example {
  3.  private float radius;
  4.  private float area;
  5.  private float b;
  6.    
  7.  public static void main(String[] args) {
  8.     int y = 1;
  9.     Example[] obj = new Example[5];
  10.     int x = 0;
  11.  
  12.    while(x<5){
  13.        obj[x] = new Example();
  14.        [x].radius = y;
  15.         y = y*2;
  16.        obj[x].area = obj[x].find(obj[x].radius);
  17.        System.out.println(" Radius " + obj[x].radius+ " Area " + obj[x].area);
  18.         x = x + 1;
  19.     }
  20. }
  21.   public float find(float rad){
  22.    b = 3.14f * rad * rad;
  23.   return b;
  24.   }
  25. }
  26.  
  27.  
  28. Output:
  29.  
  30. Radius 1.0 Area 3.14
  31. Radius 2.0 Area 12.56
  32. Radius 4.0 Area 50.24
  33. Radius 8.0 Area 200.96
  34. Radius 16.0 Area 803.84