07 February, 2011

Program java Menghitung Bangun Kerucut & Tabung

Didalam program ini user menginputkan tinggi dan jari - jari untuk bangun A dan bangun B. kemudian program mengeksekusinya sehingga akan di ketahui luas permukaan dan volume bangun A maupun bangun B, sesuai tinggi dan jari - jari yang telah di inputkan.

Berikut contoh programnya :

import java.io.*;
class fauyan {
    double r,s,t;
    double phi = 3.14;
    double volumekerucut, volumetabung;
    double luaskerucut, luastabung;
/*
Email  : f_zan.hack@yahoo.com
Web   : fzan-aquana.blogspot.com
            fauzanvs.blogspot.com
*/
    void hitung() {
        luaskerucut = (phi * r) * (s + r);
        luastabung = (phi* r * 2) * (t + r);
        System.out.println(" ");
        System.out.println("  Luas Permukaan Kerucut : " +luaskerucut +" cm^2");
        System.out.println("  Luas Permukaan Tabung : " +luastabung +" cm^2");
        System.out.println(" ");

        volumekerucut = (phi * r * r * t) / 3;
        volumetabung = t * r * r * phi;
        System.out.println("  Volume Kerucut : " +volumekerucut +" cm^3");
        System.out.println("  Volume Tabung : " +volumetabung +" cm^3");
        System.out.println("==================================================");
    }
}

class responsi {
public static void main(String[] args) throws IOException {
BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
fauyan a = new fauyan();
fauyan b = new fauyan();
 try{
    System.out.println("       MENGHITUNG BANGUN KERUCUT & TABUNG");
    System.out.println("==================================================");
    System.out.print ("Masukan Tinggi Bangun A = ");
    a.t = Integer.parseInt(dataIn.readLine());
    System.out.print ("Masukan Jari - Jari Bangun A = ");
    a.r = Integer.parseInt(dataIn.readLine());
    a.s= Math.sqrt((a.r * a.r)+(a.t * a.t));
  
    System.out.println(" ");
    System.out.print ("Masukan Tinggi Bangun B = ");
    b.t = Integer.parseInt(dataIn.readLine());
    System.out.print ("Masukan Jari - Jari Bangun B = ");
    b.r = Integer.parseInt(dataIn.readLine());
    b.s= Math.sqrt((b.r * b.r)+(b.t * b.t));
    System.out.println("==================================================");
  
    System.out.println(" ");
    System.out.println("------------------- Bangun A ----------------------");
    System.out.println(" Tinggi Bangun A : " +a.t +" cm");
    System.out.println(" Jari - Jari Bangun A : " +a.r +" cm");
    System.out.println(" Sisi Miring Bangun A : " +a.s +" cm");
    a.hitung();

    System.out.println(" ");
    System.out.println("------------------- Bangun B ----------------------");
    System.out.println(" Tinggi Bangun B : " +b.t +" cm");
    System.out.println(" Jari - Jari Bangun B : " +b.r +" cm");
    System.out.println(" Sisi Miring Bangun B : " +b.s +" cm");
    b.hitung();

    }catch( NumberFormatException e ){
    System.out.println("Salah Inputan!");
    System.exit(1);

   }
  }
}

Artikel Terkait

1 comments:

suci nurhikmah said...

:13

:10 :11 :12 :13
:14 :15 :16 :17
:18 :19 :20 :21
:22 :23 :24 :25
:26 :27 :28 :29
:30 :31 :32 :33
:34 :35 :36 :37
:38 :39 :40 :41
:42 :43 :44 :45
:46 :47 :48 :49
:50 :51 :52 :53
:54 :55 :56 :57

Post a Comment

Template by : kendhin x-template.blogspot.com ==> Editor by : BIK