Anda di halaman 1dari 2

/* * To change this template, choose Tools | Templates * and open the template in the editor.

*/ package segitiga; /** * * @author admin */ public class SegiTiga { double luas; int alas; int tinggi; void luassegi(){ luas=0.5*alas*tinggi; System.out.println("Besar luas segitiga adalah : "+luas); } } source code pada main class prisma extends segitiga /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package segitiga; /** * * @author admin */ public class Prisma extends SegiTiga { // double luas; int tinggiprisma; void volumepris(){ double volume=(0.5*alas*tinggi)*tinggiprisma; System.out.println("Besar volume Prisma adalah : "+volume); } } source code pada main class limas extends segitiga /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package segitiga; /** * * @author admin */ public class Limas extends SegiTiga { // double luas; int tinggilimas;

void volumelim(){ double volume=0.3*luas*tinggilimas; System.out.println("Besar volume limas adalah : "+volume); } } source code pada main class test.java /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package segitiga; /** * * @author admin */ public class Test { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Limas hitung=new Limas(); Prisma cari=new Prisma(); hitung.alas=10; hitung.tinggi=5; hitung.tinggilimas=8; hitung.luassegi(); hitung.volumelim(); cari.alas=10; cari.tinggi=5; cari.tinggiprisma=8; cari.volumepris();

} }

Anda mungkin juga menyukai