اكتب برنامج Java لتوضيح استخدام الأساليب في الclass

  • برمجة جافا
  • برمجة

اكتب برنامج Java لتوضيح استخدام الأساليب في الclass

الأجوبة

  1. public class Method
  2. {
  3.     void addition(int a,int b)
  4.     {
  5.         int c = a + b;
  6.         System.out.println("Result:"+c);
  7.     }
  8.     void subtraction(int a,int b)
  9.     {
  10.         int c = a - b;
  11.         System.out.println("Result:"+c);
  12.     }
  13.     void multiplication(int a,int b)
  14.     {
  15.         int c = a * b;
  16.         System.out.println("Result:"+c);
  17.     }
  18.     void division(int a,int b)
  19.     {
  20.         double c =(double)a / b;
  21.         System.out.println("Result:"+c);
  22.     }
  23.     public static void main(String args[])
  24.     {
  25.  	Method obj = new Method();
  26.         obj.addition(10, 4);
  27.         obj.subtraction(10, 4);
  28.         obj.multiplication(10,4);
    }
    }
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...