diff --git a/starter/lab3_task1.php b/starter/lab3_task1.php
index f396a7e..1a64798 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 BRANICE NAFULA
+ * @student ENE212-0088/2023
* @lab Lab 3 of 14
* @unit ICS 2371
- * @date [Date completed]
+ * @date 7TH APRIL 2026
*/
// ══════════════════════════════════════════════════════════════
@@ -68,3 +68,75 @@
echo "Config: $result
";
// TODO: Add one more chained ?? example of your own and explain it in your report.
+Exercise A - Temperature Alert system";
+$temperatures = [36.8, 39.2, 34.5];
+foreach ($temperatures as $temperature) {
+echo "Temperature: $temperature C";
+if ($temperature >= 36.1 && $temperature <= 37.5) {
+ echo "normal\n";
+}
+if ($temperature > 37.5) {
+ echo "fever\n";
+}
+if ($temperature < 36.1) {
+ echo "hypothermia warning\n";
+}
+ echo "
";
+}
+echo "
Exercise B
";
+// Even or Odd
+$number = 47;
+if ($number % 2 == 0) {
+ echo "$number is EVEN\n";
+} else {
+ echo "$number is ODD\n";
+ echo "
";
+}
+// Divisibility by 3
+if ($number % 3 == 0) {
+ echo "Divisible by 3\n";
+} else {
+ echo "Not Divisible by 3\n";
+ echo "
";
+}
+// Divisibity by 5
+if ($number % 5 == 0) {
+ echo "Divisible by 5\n";
+} else {
+ echo "Not Divisible by 5\n";
+ echo "
";
+}
+// Divisibility by 3 and 5
+if ($number % 3 == 0 && $number % 5 == 0) {
+ echo "Divisible by both 3 and 5\n";
+} else {
+ echo "Not divisible by both 3 and 5\n";
+ echo "
";
+}
+echo " Exercise C - Comparison Chain
";
+$x = 10;
+$y = "10";
+$z = 10.0;
+var_dump($x == $y);
+var_dump($x === $y);
+var_dump($x == $z);
+var_dump($x === $z);
+var_dump($y === $z);
+var_dump($x <=> $y );
+echo "
";
+echo "Exercise D - Null and Default Values
";
+$username = null;
+$display = $username ?? "Guest";
+echo "welcome, $display
";
+$config_val = null;
+$env_val = null;
+$default = "system_default";
+$result = $config_val ?? $env_val ?? $default;
+echo "Config: $result
";
+$user_color_pref = null;
+$theme_color = null;
+$fallback_color = "black";
+$final_color = $user_color_pref ?? $theme_color ?? $fallback_color;
+echo "Selected Color: $fallback_color";
+?>
diff --git a/starter/lab3_task2.php b/starter/lab3_task2.php
index b03e13c..fa867e6 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 BRANICE NAFULA
+ * @student ENE212-0088/2023
* @lab Lab 3 of 14
* @unit ICS 2371
- * @date [Date completed]
+ * @date 7TH APRIL 2026
*/
// ── Test Data Set A (change values to run other test sets) ─────────────────
-$name = "Your Name";
+$name = "BRANICE NAFULA";
$cat1 = 8; // out of 10
$cat2 = 7; // out of 10
$cat3 = 9; // out of 10
@@ -64,3 +64,63 @@
// Set C: cat1=0, cat2=0, cat3=7, cat4=0, exam=48 → expect DISQUALIFIED
// Set D: cat1=5, cat2=4, cat3=6, cat4=3, exam=22 → expect grade D + supp eligible
// Set E: cat1=0, cat2=0, cat3=0, cat4=0, exam=15 → expect DISQUALIFIED
+ 0) {
+ $attendance_count++;
+ }
+}
+if ($attendance_count >= 3) {
+ if ($exam >= 20) {
+ $status = "Qualified";
+ } else {
+ $status = "Disqualified - Exam condition not met";
+ }
+} else {
+ $status = "Disqualified - Exam conditions not met";
+}
+//Determining the grade
+if ($total >= 70) {
+ $grade = "A";
+ $description = "Distinction";
+} elseif ($total >= 65) {
+ $grade = "B+";
+ $description = "Credit Upper";
+} elseif ($total >= 60) {
+ $grade = "B";
+ $description = "Credit Lower";
+} elseif ($total >= 55) {
+ $grade = "C+";
+ $description = "Pass Upper";
+} elseif ($total >= 50) {
+ $grade = "C";
+ $description = "Pass Lower";
+} else if ($total >= 40) {
+ $grade = "D";
+ $description = "Marginal Pass";
+} else {
+ $grade = "E";
+ $description = "Fail";
+}
+//Supplimentary Rule
+$supp_status = ($grade === "D")
+? "Eligible for supplimentary Exam"
+: "Not eligible for supplimentary Exams";
+//Displaying Results
+echo "Students Results
";
+echo "Total Marks: $total / 100
";
+echo "Eligibility: $status
";
+echo "Grade: $grade ($description)
";
+echo "Supplimentary Status: $supp_status
";
+?>
diff --git a/starter/lab3_task3.php b/starter/lab3_task3.php
index d9e00c8..41a8212 100644
--- a/starter/lab3_task3.php
+++ b/starter/lab3_task3.php
@@ -3,11 +3,11 @@
* 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 BRANICE NAFULA
+ * @student ENE212-0088/2023
* @lab Lab 3 of 14
* @unit ICS 2371
- * @date [Date completed]
+ * @date 7TH APRIL 2026
*/
// ══════════════════════════════════════════════════════════════
@@ -59,3 +59,71 @@
// 1. What is the key difference between switch (==) and match (===)?
// 2. Give one example where this difference changes the output.
// 3. When would you prefer switch over match, and why?
+Exercise A - Day of week classifier";
+$day = 1;
+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 number";
+ break;
+}
+echo "HTTP status code explainer
";
+$status_code = 404;
+switch ($status_code){
+ case 200:
+ echo "200: OK";
+ break;
+ case 301:
+ echo "301: Moved permanently";
+ break;
+ case 400:
+ echo "400: Bad request";
+ break;
+ case 401:
+ echo "401: Unauthorised";
+ break;
+ case 403:
+ echo "403: Forbidden";
+ break;
+ case 404:
+ echo "404: Not found";
+ break;
+ case 500:
+ echo "500: Internal server error";
+ break;
+ default:
+ echo "Unknown status code";
+ break;
+}
+echo "Exercise C - PHP 8 match
";
+$status_code = 404;
+$explanation = match ($status_code) {
+ 200 => "OK",
+ 301 => "Moved Permanently",
+ 400 => "Bad Request",
+ 403 => "Forbidden",
+ 404 => "Not Found",
+ 500 => "Internal Server Error",
+ default => "Unknown Status Code",
+};
+echo "status $status_code: $explanation";
+?>
\ No newline at end of file
diff --git a/starter/lab3_task4.php b/starter/lab3_task4.php
index 2a3d225..c687ff3 100644
--- a/starter/lab3_task4.php
+++ b/starter/lab3_task4.php
@@ -6,11 +6,11 @@
* IMPORTANT: You must complete pseudocode AND flowchart in your PDF
* report BEFORE writing any code below.
*
- * @author [Your Full Name]
- * @student [Your Reg Number, e.g. SCT212-XXXX/2024]
+ * @author BRANICE NAFULA
+ * @student ENE212-0088/2023
* @lab Lab 3 of 14
* @unit ICS 2371
- * @date [Date completed]
+ * @date 7TH APRIL 2026
*/
// ── Problem: Student Loan Eligibility System ───────────────────────────────
@@ -57,3 +57,33 @@
// Set C: enrolled=false, gpa=3.5, income=60000, previous=true → Not enrolled
// Set D: enrolled=true, gpa=2.5, income=600000, previous=true → Income fail
// Set E: enrolled=true, gpa=2.0, income=50000, previous=true → Full | Renewal
+HELB Loan Eligibility Checker";
+$enrolled = true;
+$gpa = 3.1;
+$annual_income = 180000;
+$previous_loan = false;
+if (!$enrolled) {
+ $result = "Not eligible - must be an active student";
+} else {
+ if ($gpa < 2.0) {
+ $result = "Not eligible - GPA below minimum";
+ } else {
+ if ($annual_income < 100000) {
+ $loan_amount = "Full Loan";
+ } elseif ($annual_income < 250000) {
+ $loan_amount = "Partial 75%";
+ } elseif ($annual_income < 500000) {
+ $loan_amount = "Partial 50%";
+ } else {
+ $loan_amount = null;
+ }
+ if ($loan_amount) {
+ $app_type = ($previous_loan) ?
+"Renewal application" : "New application";
+ $result = "$loan_amount | $app_type";
+ }
+ }
+}
+echo "status: $result";
+?>
\ No newline at end of file