Tuesday, August 6, 2019

PROGRAM CLASS METHOD HITUNG JAVA

PENJUMLAHAN, PENGURANGAN, PERKALIAN DAN PEMBAGIAN
class DemoMethod2 {

  /* Membuat method berparameter penjumlahan,
  * pengurangan, perkalian dan pembagian
  */
 void penjumlahan(int a, int b){
  System.out.println("Nilai " + a + " + " + b + " = " + (a+b));
 }

 void pengurangan(int a, int b){
  System.out.println("Nilai " + a + " - " + b + " = " + (a-b));
 }
 void perkalian(int a, int b){
  System.out.println("Nilai " + a + " x " + b + " = " + (a*b));
 }

 void pembagian(int a, int b){
  System.out.println("Nilai " + a + " / " + b + " = " + (a/b));
 }

 public static void main(String[] args) {

  DemoMethod2 demoMethod = new DemoMethod2();

    // memanggil method
  demoMethod.penjumlahan(3, 5);
  demoMethod.pengurangan(5, 4);
  demoMethod.perkalian(4, 5);
  demoMethod.pembagian(10, 2);

 }

}

No comments:

Post a Comment

Business Communication

What is Business Communication?? Business Communication is all about presenting your ideas clearly and effectively. Ideas can be the im...