<?php // ========================================================= // PART 1: ARITHMETIC OPERATIONS & LOOPING (5 STUDENTS) // ========================================================= // Array representing 5 students with 3 exam scores each $students = [ "Student 1" => [88, 92, 96], // Qualifies for Honor Roll "Student 2" => [45, 48, 42], // Fail status "Student 3" => [91, 85, 90], // High average, no score > 95 "Student 4" => [65, 72, 58], // Pass status "Student 5" => [30, 40, 50] // Fail status ]; echo "=========================================\n"; echo " STUDENT GRADE PROCESSING SYSTEM \n"; echo "=========================================\n\n"; // Task 2.3: Loop to process grades for 5 students foreach ($students as $studentName => $scores) { echo "--- " . strtoupper($studentName) . " ---\n"; $score1 = $scores[0]; $score2 = $scores[1]; $score3 = $scores[2]; // Task 1.1: Calculate average score $average = ($score1 + $score2 + $score3) / 3; // Task 1.2: Calculate percentage score out of 300 marks $totalMarks = $score1 + $score2 + $score3; $percentage = ($totalMarks / 300) * 100; echo "Scores: " . $score1 . ", " . $score2 . ", " . $score3 . "\n"; echo "Average Score: " . number_format($average, 2) . "\n"; echo "Percentage: " . number_format($percentage, 2) . "%\n"; // Task 2.1: Pass or Fail logic based on average score if ($average >= 50) { echo "Status: PASS\n"; } else { echo "Status: FAIL\n"; } // Task 2.2: Honor Roll evaluation logic if ($average > 90 && ($score1 > 95 || $score2 > 95 || $score3 > 95)) { echo "NOTICE: Student qualifies for the Honor Roll!\n"; } echo "\n"; } // ========================================================= // PART 2: ACADEMIC PROBATION CHECK (5 SUBJECTS) // ========================================================= echo "=========================================\n"; echo " ACADEMIC PROBATION EVALUATION \n"; echo "=========================================\n\n"; // Task 1.3: Input marks for 5 subjects for a sample student $subjectMarks = [42, 85, 48, 90, 35]; $failedSubjectsCount = 0; // Count subjects below 50 foreach ($subjectMarks as $mark) { if ($mark < 50) { $failedSubjectsCount++; } } echo "Subject Marks: " . implode(", ", $subjectMarks) . "\n"; echo "Total Failed Subjects: " . $failedSubjectsCount . "\n\n"; // Warning trigger if student fails more than 2 subjects if ($failedSubjectsCount > 2) { echo "WARNING: Student is placed on academic probation.\n"; } else { echo "STATUS: Student is in good academic standing.\n"; } ?>
You have javascript disabled. You will not be able to edit any code.