Wednesday, December 21, 2011

Java program for finding area and volume of a circle


import java.util.*;

public class Ch1Q37
{
 public static void main(String[] args)
  {
  double sarea, vol;
  System.out.print("Enter radius of a sphere: ");
  Scanner kbd = new Scanner(System.in);
  double rad = kbd.nextDouble();
  sarea = 4*Math.PI*rad*rad;
     vol = Math.PI*rad*rad*rad*4/3;
  System.out.println("Surface area = " + sarea);
     System.out.println("Volume = " + vol);  
    }
}

No comments:

Post a Comment