Senin, 01 April 2013

Program Java : Menghitung Volume dan Luas Permukaan Bola - Data Input Stream


public class bola1
{
 public static void main(String[]args)
 {
 DataInputStream show=new DataInputStream(System.in);
 try
 {
 final float phi=3.14f;
 String rad;
 float rads,volume,luasPermukaan;
 System.out.print("Masukkan Radius:");
 rad=show.readLine();
 rads=Float.parseFloat(rad);
 
 volume=(4/3)*phi*rads*rads*rads;
 luasPermukaan=4*phi*rads*rads;

 System.out.println("Hasil");
 System.out.println("Volume:"+volume);
 System.out.println("Luas Permukaan:"+luasPermukaan);
 }
 catch(IOException ioe)
 {
 System.out.println("Error");
 }
 }
}

Tidak ada komentar:

Posting Komentar

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Hosted Desktop | Modified by AkaChopa| akachopa.com