Tugas 2 PBO Kelas B

Berikut adalah hasil pengerjaan tugas 2 menghitung luas bangun ruang dengan Bahasa Java dalam BlueJ

Hasil :












Class :















Sourcecode :

Main

 /**  
  * Ini Main  
  *  
  * @author (Muhammad Husni Ridhart Azzikry)  
  * @version (Senin 10 September 2018)  
  */  
 class Main3d  
 {  
   public static void main(String args[])  
   {  
     Cube aCube;   //Ref Cube  
     aCube = new Cube(); //New Cube  
     aCube.s = 5.0;   //Data Input  
     double surfacec = aCube.SAC();  
     double volumec = aCube.VC();  
     System.out.println("Side Length Cube ="+aCube.s+" Cube Surface ="+surfacec);  
     System.out.println("Side Length Cube ="+aCube.s+" Cube Volume ="+volumec);  
     System.out.println("====================================");  
     Block aBlock;    //Ref Block  
     aBlock = new Block();  //New Block  
     aBlock.p = 7.0;   //Data Input  
     aBlock.l = 6.0;  
     aBlock.t = 5.0;  
     double surfaceb = aBlock.SAB();  
     double volumeb = aBlock.VB();  
     System.out.println("Panjang Balok ="+aBlock.p);  
     System.out.println("Lebar Balok ="+aBlock.l);  
     System.out.println("Tinggi Balok ="+aBlock.t);  
     System.out.println("Block Surface ="+surfaceb+" Block Volume ="+volumeb);  
     System.out.println("====================================");  
     Tube aTube;   //Ref Tube  
     aTube = new Tube();   //New Tube  
     aTube.r = 7.0;   //Data Input  
     aTube.t = 12.0;  
     double surfacet = aTube.SAT();  
     double volumet = aTube.VT();  
     System.out.println("Radius Tabung ="+aTube.r);  
     System.out.println("Tinggi Tabung ="+aTube.t);  
     System.out.println("Tube Surface ="+surfacet+" Tube Volume ="+volumet);  
     System.out.println("====================================");  
     Ball aBall;   //Ref Ball  
     aBall = new Ball();   //New Ball  
     aBall.r = 14.0;   //Data Input  
     double surface = aBall.SABL();  
     double volume = aBall.VBL();  
     System.out.println("Radius Bola ="+aBall.r);  
     System.out.println("Ball Surface ="+surface+" Ball Volume ="+volume);  
   }  
 }    

Class Cube

 /** Ini untuk Kubus */  
 public class Cube  
 {  
   double s; // Declare panjang lebar dan tinggi  
   public double SAC() //Count result of Cube Surface Area  
   { return 6*s*s; }  
   public double VC() // Count result of Cube Volume  
   { return s*s*s; }  
 }  

Class Block

 /** Ini buat Balok*/  
 public class Block  
 {  
   public double p,l,t; //Declare Panjang Lebar Tinggi  
   public double SAB()  
   { return 2*(p+l)+2*(p+t)+2*(l+t);}  
   public double VB()  
   { return p*l*t ; }  
 }  

Class Tube

 /** Ini Buat Tabung */  
 public class Tube  
 {  
   public double r,t; // Declare Radius dan Tinggi  
   public double SAT()  
   { return 2*3.14*r*t ;} // Show Surface Area  
   public double VT()  
   { return 3.14*r*r*t ;} // Show Volume  
 }  

Class Ball

 /** Ini buat Bola*/  
 public class Ball  
 {  
   double r; //Declare Radius  
   public double SABL()  
   { return 4*3.14*r*r; } //Show Surface Area  
   public double VBL()  
   { return 4/3*3.14*r*r*r; } //Show Volume  
 }  

Komentar

Postingan Populer