Advertisement
Banta_Sandra

Program Luas & Keliling Lingkaran Dengan Konsep OOP

Mar 24th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. Buat Sebuah Project Dengan Nama "latihan", kemudian buat sebuah class dengan nama "rumus" ketikkan code dibawah.
  2. Setelah itu, Buat class baru dengan nama "DisplayLuas_Keliling_Lingkaran", Kemudian ketikkan codding tahap ke-2 dibawah, baru di jalankan
  3.  
  4. ---------------------------------------------------------------------------------------------------------------------
  5.  
  6. /*
  7.  * To change this template, choose Tools | Templates
  8.  * and open the template in the editor.
  9.  */
  10. package latihan;
  11.  
  12. /**
  13.  *
  14.  * @author Bengkel IT Lhokseumawe
  15.  */
  16. public class rumus {
  17.     private float pi= (float) 3.14;
  18.     private float radius=5;
  19.    
  20.     public void luas(){
  21.         float luas= pi*radius*radius;
  22.         System.out.println("Luas: "+luas);
  23.        
  24.     }
  25.     public void keliling(){
  26.        
  27.         float keliling= 2* pi*radius;
  28.         System.out.println("Keliling: "+keliling);
  29.     }
  30. }
  31.  
  32.  
  33. CODDING TAHAP KE-II
  34. --------------------
  35.  
  36. /*
  37.  * To change this template, choose Tools | Templates
  38.  * and open the template in the editor.
  39.  */
  40. package latihan;
  41.  
  42. /**
  43.  *
  44.  * @author BIT
  45.  */
  46. public class DisplayLuas_Keliling_Lingkaran {
  47. public static void main(String[]args){
  48.    
  49.     rumus display1= new rumus();
  50.     rumus display2= new rumus();
  51.    
  52.     display1.luas();
  53.     display2.keliling();
  54.    
  55. }
  56.    
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement