Advertisement
xathrya

Untitled

Jul 16th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. Nama : Imam Mashur
  3. Kelas : XII TKJ 1
  4. NIS : 2011113
  5.  
  6. buatlah program utk menghitung rata2 menggunakan konsep pemrograman berorientasi objek
  7. */
  8. public class rata2 {
  9.     double jumlah;
  10.     double hrgWxp;  //harga windows xp
  11.     double hrgW7;   //harga windows 7
  12.     double hrgW8;
  13.     double ratata = winXP()+win7()+win8();//Pengolahan rata-rata
  14.    
  15.    
  16.     public void inputData(int data)
  17.     {
  18.         jumlah = data;
  19.     }
  20.    
  21.     double winXP() //objek windows xp
  22.     {
  23.         return hrgWxp = 290000;
  24.     }
  25.    
  26.     double win7() //objek windows 7
  27.     {
  28.         return hrgW7 = 565000;
  29.     }
  30.    
  31.     double win8()
  32.     {
  33.         return hrgW8 = 999000;
  34.     }
  35.     public void cetak() {
  36.         System.out.print("harga rata-rata windows di kaskus ialah "+ratata);
  37.     }
  38.    
  39.     public void nilai() {
  40.         System.out.println(ratata);
  41.     }
  42.    
  43.     public static void main(String[] args)
  44.     {
  45.         rata2 ratax=new rata2();
  46.  
  47.         ratax.inputData(3);
  48.         ratax.cetak();
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement