Source :
public class segitigasikuconstruktor {
private double alas;
private double sisiM;
private double tinggi;
private double luas;
private double kell;
private String Nama;
private String Nim;
private String Fak;
public segitigasikuconstruktor (String Nama,String Nim,String Fak){
this.Nama=Nama;
this.Nim=Nim;
this.Fak=Fak;
System.out.println("===========================");
System.out.println("Nama :"+Nama);
System.out.println("Nim :"+Nim);
System.out.println("Fakultas:"+Fak);
System.out.println("===========================");
}
public segitigasikuconstruktor(double alas,double sisiM,double tinggi){
this.alas=alas;
this.sisiM=sisiM;
this.tinggi=tinggi;
}
public segitigasikuconstruktor(){
}
public double getluas(){
luas=0.5*alas*tinggi;
return luas;
}
public double getkeliling(){
kell=sisiM+alas+tinggi;
return kell;
}
public void printsegitiga(double alas,double sisiM,double tinggi){
System.out.println("Segitiga Siku-Siku :");
System.out.println("===========================");
System.out.println("Alas = " + alas);
System.out.println("Sisi Miring = " + sisiM);
System.out.println("Tinggi = " + tinggi);
}
public void printsegitiga(double luas,double kell){
System.out.println();
System.out.println("Luas = " + luas);
System.out.println("Keliling = " + kell );
System.out.println("============================");
}
public double getalas(){
return alas;
}
public void setalas( double alas ){
this.alas=alas;
}
public double getsisiM(){
return sisiM;
}
public void setsisiM(double sisiM){
this.sisiM=sisiM;
}
public double gettinggi(){
return tinggi;
}
public void settinggi(double tinggi){
this.tinggi=tinggi;
}
public static void main(String[] args) {
segitigasikuconstruktor a= new segitigasikuconstruktor();
segitigasikuconstruktor b= new segitigasikuconstruktor("David Ibrahim","2012420096","Teknik Informatika");
segitigasikuconstruktor c= new segitigasikuconstruktor(20, 25, 35);
c.printsegitiga(c.getalas(),c.getsisiM(),c.gettinggi());
c.printsegitiga(c.getluas(),c.getkeliling());
}
}
Output :
Nama : David Ibrahim
Nim : 2012420096
Fakultas : Teknik Informatika
Unitomo
Posted by 22.24 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar