//--------------------
//finalWord.java
//--------------------
package ObjekDanClass;
public class finalWord {
final double phi = 3.14;
double kelilingLingkaran(double jari) {
double keliling;
keliling = 2 * phi * jari;
return keliling;
}
double luasLingkaran(double jari) {
double luas;
luas = phi * jari * jari;
return luas;
}
}
public class finalWord {
final double phi = 3.14;
double kelilingLingkaran(double jari) {
double keliling;
keliling = 2 * phi * jari;
return keliling;
}
double luasLingkaran(double jari) {
double luas;
luas = phi * jari * jari;
return luas;
}
}
//--------------------------------------------------------
//--------------------
//pengujian.java
//--------------------
package ObjekDanClass;
public class pengujian {
public static void main(String args[]) {
finalWord o = new finalWord();
System.out.println("keliling " + o.kelilingLingkaran(2));
System.out.println("luas " + o.luasLingkaran(3));
}
}
luas 28.259999999999998
BUILD SUCCESSFUL (total time: 0 seconds)
public class pengujian {
public static void main(String args[]) {
finalWord o = new finalWord();
System.out.println("keliling " + o.kelilingLingkaran(2));
System.out.println("luas " + o.luasLingkaran(3));
}
}
//--------------------
//output
//--------------------
keliling 12.56luas 28.259999999999998
BUILD SUCCESSFUL (total time: 0 seconds)
0 comments:
Posting Komentar