diff --git a/starter/lab3_task1.php b/starter/lab3_task1.php
index f396a7e..00525ba 100644
--- a/starter/lab3_task1.php
+++ b/starter/lab3_task1.php
@@ -3,11 +3,11 @@
* ICS 2371 — Lab 3: Control Structures I
* Task 1: Simple if and if-else — Warm-Up Exercises [5 marks]
*
- * @author [Your Full Name]
- * @student [Your Reg Number, e.g. SCT212-XXXX/2024]
+ * @author [MUTWIRI KELVIN MWENDA]
+ * @student [ENE212-0067/2023]
* @lab Lab 3 of 14
* @unit ICS 2371
- * @date [Date completed]
+ * @date [4TH APRIL 2026]
*/
// ══════════════════════════════════════════════════════════════
@@ -21,7 +21,17 @@
// Test with: 36.8, 39.2, 34.5 — screenshot each
// TODO: Exercise A — your code here
+$temperature = 34.5;
+if ($temperature >= 36.1 && $temperature <= 37.5) {
+ echo "Normal
";
+}
+if ($temperature > 37.5) {
+ echo "Fever
";
+}
+if ($temperature < 36.1) {
+ echo "Hypothermia Warning
";
+}
// ══════════════════════════════════════════════════════════════
// EXERCISE B — Even or Odd
@@ -32,6 +42,25 @@
// TODO: Exercise B — your code here
+$number = 47;
+
+if ($number % 2 == 0) {
+ echo "$number is EVEN
";
+} else {
+ echo "$number is ODD
";
+}
+
+if ($number % 3 == 0) {
+ echo "$number is divisible by 3
";
+}
+
+if ($number % 5 == 0) {
+ echo "$number is divisible by 5
";
+}
+
+if ($number % 3 == 0 && $number % 5 == 0) {
+ echo "$number is divisible by both 3 and 5
";
+}
// ══════════════════════════════════════════════════════════════
// EXERCISE C — Comparison Chain
@@ -68,3 +97,10 @@
echo "Config: $result
";
// TODO: Add one more chained ?? example of your own and explain it in your report.
+$cloudinary_api_url = null; // Primary source: Imagine the API didn't return an image
+$local_upload_url = null; // Secondary source: Imagine no local file was uploaded either
+$placeholder_image = "default_avatar.jpg"; // Fallback source
+
+$final_image_to_load = $cloudinary_api_url ?? $local_upload_url ?? $placeholder_image;
+
+echo "Image source to load: $final_image_to_load
";
\ No newline at end of file
diff --git a/starter/lab3_task2.php b/starter/lab3_task2.php
index b03e13c..f8a5daa 100644
--- a/starter/lab3_task2.php
+++ b/starter/lab3_task2.php
@@ -7,15 +7,15 @@
* report BEFORE writing any code below. Marks are awarded for all
* three components: pseudocode, flowchart, and working code.
*
- * @author [Your Full Name]
- * @student [Your Reg Number, e.g. SCT212-XXXX/2024]
+ * @author [MUTWIRI KELVIN MWENDA]
+ * @student [ENE212-0067/2023]
* @lab Lab 3 of 14
* @unit ICS 2371
- * @date [Date completed]
+ * @date [4TH APRIL 2026]
*/
// ── Test Data Set A (change values to run other test sets) ─────────────────
-$name = "Your Name";
+$name = "MUTWIRI KELVIN MWENDA";
$cat1 = 8; // out of 10
$cat2 = 7; // out of 10
$cat3 = 9; // out of 10
@@ -42,21 +42,55 @@
// ── STEP 1: Compute total ─────────────────────────────────────────────────
// TODO: compute $total
+$total = $cat1 + $cat2 + $cat3 + $cat4 + $exam;
// ── STEP 2: Count CATs attended ───────────────────────────────────────────
// TODO: compute $cats_attended (each CAT > 0 counts as attended)
-
+$cats_attended = 0;
+if ($cat1 > 0) $cats_attended++;
+if ($cat2 > 0) $cats_attended++;
+if ($cat3 > 0) $cats_attended++;
+if ($cat4 > 0) $cats_attended++;
// ── STEP 3: Eligibility check (nested if) ─────────────────────────────────
// TODO: nested if — eligibility → grade classification → supplementary ternary
-
+if ($cats_attended >= 3 && $exam >= 20) {
+ // Eligible — determine grade
+ if ($total >= 70) {
+ $grade = "A";
+ } elseif ($total >= 65) {
+ $grade = "B+";
+ } elseif ($total >= 60) {
+ $grade = "B";
+ } elseif ($total >= 55) {
+ $grade = "C+";
+ } elseif ($total >= 50) {
+ $grade = "C";
+ } elseif ($total >= 40) {
+ $grade = "D";
+ } else {
+ $grade = "E";
+ }
+} else {
+ // Not eligible
+ $grade = "DISQUALIFIED — Exam conditions not met";
+}
+$supplementary_status = ($grade == "D") ? "Eligible for Supplementary Exam" : "Not eligible for supplementary";
// ── STEP 4: Display formatted HTML report card ────────────────────────────
// TODO: output a clear, formatted report card showing:
// student name, each CAT score, exam score, total,
// cats attended, eligibility status, grade, remark, supplementary status
-
+echo "
Student Name: $name
"; +echo "CAT Scores: $cat1, $cat2, $cat3, $cat4
"; +echo "Exam Score: $exam
"; +echo "Total: $total
"; +echo "CATs Attended: $cats_attended
"; +echo "Eligibility Status: " . ($cats_attended >= 3 && $exam >= 20 ? "Eligible" : "Not Eligible") . "
"; +echo "Grade: $grade
"; +echo "Supplementary Status: $supplementary_status
"; // ── Required Test Data Sets — screenshot each ───────────────────────────── // Set A: cat1=8, cat2=7, cat3=9, cat4=6, exam=52 → expect grade B diff --git a/starter/lab3_task3.php b/starter/lab3_task3.php index d9e00c8..532559a 100644 --- a/starter/lab3_task3.php +++ b/starter/lab3_task3.php @@ -3,16 +3,16 @@ * ICS 2371 — Lab 3: Control Structures I * Task 3: switch-case and match Expression [6 marks] * - * @author [Your Full Name] - * @student [Your Reg Number, e.g. SCT212-XXXX/2024] + * @author [MUTWIRI KELVIN MWENDA] + * @student [ENE212-0067/2023] * @lab Lab 3 of 14 * @unit ICS 2371 - * @date [Date completed] + * @date [4TH APRIL 2026] */ // ══════════════════════════════════════════════════════════════ // EXERCISE A — Day of Week Classifier -// ══════════════════════════════════════════════════════════════ +// ══════════════════════════════════════════════════════ // Given $day (integer 1–7, where 1=Monday): // Use switch-case to print the day name. // Group Saturday and Sunday under "Weekend". @@ -22,8 +22,30 @@ $day = 3; // change this to test all cases // TODO: switch-case for day classifier - - +switch ($day) { + case 1: + echo "Monday — Lecture day"; + break; + case 2: + echo "Tuesday — Lecture day"; + break; + case 3: + echo "Wednesday — Lecture day"; + break; + case 4: + echo "Thursday — Lecture day"; + break; + case 5: + echo "Friday — Lecture day"; + break; + case 6: + case 7: + echo "Weekend"; + break; + default: + echo "Invalid day"; +} +echo "