The Code Fix

شرح Java

الشروط والحلقات

الشروط (if / else)

int age = 18;

if (age >= 18) {
    System.out.println("بالغ");
} else {
    System.out.println("قاصر");
}

else if

int score = 85;

if (score >= 90) {
    System.out.println("ممتاز");
} else if (score >= 75) {
    System.out.println("جيد جدًا");
} else {
    System.out.println("مقبول");
}

switch

int day = 3;

switch (day) {
    case 1: System.out.println("الأحد"); break;
    case 2: System.out.println("الاثنين"); break;
    default: System.out.println("يوم آخر");
}

حلقة for

for (int i = 1; i <= 5; i++) {
    System.out.println(i);
}

حلقة while

int count = 1;
while (count <= 3) {
    System.out.println(count);
    count++;
}

for-each (للمصفوفات)

int[] numbers = {10, 20, 30};
for (int n : numbers) {
    System.out.println(n);
}

🎯 التالي: الدوال (Methods).