buat java aplikasi dengan nama ContohParameter
public class ContohParameter {
public static void main(String[] args) {
Matematika mtk = new Matematika();
int a = mtk.tambah(100, 50);
System.out.println(a);
a = mtk.kurang(255, 75);
System.out.println(a);
double b = mtk.bagi(100.0, 3.0);
System.out.println(b);
}
}
public class ContohParameter {
public static void main(String[] args) {
Matematika mtk = new Matematika();
int a = mtk.tambah(100, 50);
System.out.println(a);
a = mtk.kurang(255, 75);
System.out.println(a);
double b = mtk.bagi(100.0, 3.0);
System.out.println(b);
}
}
buat class dengan nama Matematika
public class Matematika {
int tambah(int nilai1, int nilai2){
int hasil = nilai1 + nilai2;
return hasil;
}
int kurang(int nilai1, int nilai2){
int hasil = nilai1 - nilai2;
return hasil;
}
int kali(int nilai1, int nilai2){
int hasil = nilai1 * nilai2;
return hasil;
}
double bagi(double nilai1, double nilai2){
double hasil = nilai1 / nilai2;
return hasil;
}
}
No comments:
Post a Comment