الآلة الحاسبة الذكية

مشروع الطالب | منصة QUREO
صورة الطالب

البراء رضا جناح

الصف الأول الثانوي فصل 1/1

عنوان المشروع البرمجي:

تطبيق الآلة الحاسبة التفاعلية

فكرة المشروع

يهدف هذا المشروع إلى برمجة آلة حاسبة تفاعلية باستخدام تقنيات الويب الأساسية (HTML لتكوين الهيكل، CSS للتصميم اللوني المريح للعين، و JavaScript لبرمجة العمليات الحسابية والمنطق). يعكس هذا المشروع قدرة الطالب على دمج التقنيات الثلاث لإنتاج تطبيق مفيد وقابل للاستخدام المباشر.

SOURCE CODE

<!-- كود الآلة الحاسبة الذكية - إعداد الطالب البراء جناح -->
<!DOCTYPE html>
<html dir="rtl">
<head>
  <style>
    body { font-family: Arial, sans-serif; background: #f0f9ff; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
    .calculator { background: white; padding: 20px; border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 100%; max-width: 300px; }
    input { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 8px; font-size: 16px; box-sizing: border-box; }
    .buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
    button { padding: 15px; background: #2563eb; color: white; border: none; border-radius: 8px; font-size: 18px; cursor: pointer; transition: 0.2s; }
    button:hover { background: #1d4ed8; }
    .btn-op { background: #eab308; color: #0f172a; font-weight: bold; }
    .btn-op:hover { background: #ca8a04; }
    .btn-clear { background: #ef4444; grid-column: span 4; }
    .btn-clear:hover { background: #dc2626; }
    #result { margin-top: 15px; padding: 15px; background: #dbeafe; color: #1e3a8a; border-radius: 8px; font-weight: bold; text-align: center; }
  </style>
</head>
<body>

  <div class="calculator">
    <h3 style="text-align: center; color: #0f172a; margin-top:0;">آلتي الحاسبة</h3>
    <input type="number" id="num1" placeholder="الرقم الأول">
    <input type="number" id="num2" placeholder="الرقم الثاني">
    
    <div class="buttons">
      <button class="btn-op" onclick="calc('+')">+</button>
      <button class="btn-op" onclick="calc('-')">-</button>
      <button class="btn-op" onclick="calc('*')">×</button>
      <button class="btn-op" onclick="calc('/')">÷</button>
      <button class="btn-clear" onclick="clearFields()">مسح (C)</button>
    </div>

    <div id="result">النتيجة ستظهر هنا</div>
  </div>

  <script>
    function calc(operation) {
      let n1 = parseFloat(document.getElementById('num1').value);
      let n2 = parseFloat(document.getElementById('num2').value);
      let resDisplay = document.getElementById('result');

      if(isNaN(n1) || isNaN(n2)) {
        resDisplay.innerHTML = "رجاءً أدخل أرقاماً صحيحة!";
        return;
      }

      let result = 0;
      if(operation === '+') result = n1 + n2;
      else if(operation === '-') result = n1 - n2;
      else if(operation === '*') result = n1 * n2;
      else if(operation === '/') {
        if(n2 === 0) { resDisplay.innerHTML = "لا يمكن القسمة على صفر!"; return; }
        result = n1 / n2;
      }
      resDisplay.innerHTML = "النتيجة: " + result;
    }

    function clearFields() {
      document.getElementById('num1').value = '';
      document.getElementById('num2').value = '';
      document.getElementById('result').innerHTML = 'النتيجة ستظهر هنا';
    }
  </script>
</body>
</html>
نتيجة التنفيذ

اضغط على "تشغيل المشروع" لرؤية النتيجة

تم التنفيذ والمراجعة تحت إشراف معلم أول المادة:

المهندس/ محمد محمود شاهين

مدرسة الشهيد أحمد مالك الثانوية

إدارة قلين التعليمية