Mencari Volume Tabung, Luas Selimut tabung, dan Luas permukaan Tabung
/*
* To change this
template, choose Tools | Templates
* and open the
template in the editor.
*/
package AcessorMutatorOverloading;
import javax.swing.JOptionPane;
/**
*
* @author Toshiba
*/
public class TabungAcessorMutatorOverloading {
double jarijari;
double tinggi;
double pi = 3.14;
float
luasPermukaan;
double
LuasSelimut;
int voll;
int luas;
//Acessor Mutator
public int
getvoll(){
return voll;
}
public void
setvoll(int Volume){
voll = Volume;
}
public float
getluasPermukaan(){
return
luasPermukaan;
}
public void
setluasPermukaan(float permukaan){
luasPermukaan =
permukaan;
}
public double
getLuasSelimut(){
return
LuasSelimut;
}
public void
setLuasSelimut(double selimut){
LuasSelimut =
selimut;
}
public void
setjarijari(int r){
jarijari = r;
}
public void
settinggi(float t){
tinggi = t;
}
//OVERLOADING
public void semua(){
System.out.println("Jarijari Tabung =
"+jarijari+"\n"
+"Tinggi Tabung = "+tinggi+"\n");}
public void luas
(int Volume){
voll = (int)
(pi*jarijari*jarijari*tinggi);
System.out.println("Volume Tabung = "+voll+"
Cm3");
}
public void
luas(double Selimut){
LuasSelimut=(2*pi*jarijari*tinggi
);
System.out.println("Luas Selimut Tabung = "+LuasSelimut+"
Cm3");
}
public void
luas(float Permukaan){
luasPermukaan=
(float) (2*pi*jarijari*(jarijari+tinggi));
System.out.println("luas permukaan Tabung =
"+luasPermukaan+" Cm3");
}
public static void
main(String[] args) {
// TODO code
application logic here
TabungAcessorMutatorOverloading x = new
TabungAcessorMutatorOverloading();
//INPUTAN
x.setjarijari(Integer.parseInt(JOptionPane.showInputDialog("Massukkan
Jari jari Tabung")));
x.settinggi(Integer.parseInt(JOptionPane.showInputDialog("Massukkan
tinggi Tabung")));
//OUTPUT
x.semua();
x.luas(x.getvoll());
x.luas(x.getLuasSelimut());
x.luas(x.getluasPermukaan());
}
}
Hasil Outputnya
Atau download Filenya disini
Nama : Bagus Dermawan
Nim : 2012420050
Posted by 02.31 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar