BCA Student Stories & UpdatesLive
Control Flow: Decision Making with if, else if, else & switch Statements
Conditional statements direct the flow of program execution based on runtime conditions. When programs evaluate user inputs or calculation outputs, conditionals determine which branch of code executes.
Day 23 Step-by-Step Practical Flow
🎯1. What You Will Learn Today
Control Flow: Decision Making with if, else if, else & switch Statements — Comprehensive Practical Guide
Har concept ko visual mental models, code anatomy aur practical industry tips ke sath samjhein.
Conditional statements direct the flow of program execution based on runtime conditions. When programs evaluate user inputs or calculation outputs, conditionals determine which branch of code executes.
"Think of conditional branching like a railway junction switch: based on the destination code signal, the track physically shifts to direct the train down track A, track B, or the main line."
👨🏫3. Teacher Demonstration Code
See how marks are classified into letter grades, and how a switch evaluates day schedules.
<!DOCTYPE html>
<html>
<body>
<script>
const score = 84;
let letterGrade = "";
if (score >= 90) {
letterGrade = "A+";
} else if (score >= 75) {
letterGrade = "A";
} else if (score >= 60) {
letterGrade = "B";
} else {
letterGrade = "C";
}
console.log(`Score ${score} receives Grade: ${letterGrade}`);
// Switch case example
const dayOfWeek = "Monday";
switch (dayOfWeek) {
case "Monday":
console.log("Schedule: BCA BCS-011 Practical Lab");
break;
case "Wednesday":
console.log("Schedule: Mathematics Tutorial");
break;
default:
console.log("Schedule: Self-Study & Revision");
}
</script>
</body>
</html>2. Hands-On Practical Lab: Follow Instructions in VS Code
Code like a professional software engineer! Follow the step-by-step instructions below in Visual Studio Code (VS Code) on your PC, test your output locally, and push to GitHub.
Day 23 Practical Task Test Studio
Check if marks >= 75 to assign award = "Distinction", else if marks >= 60 to assign award = "First Class", else award = "Pass".
Log the award variable using console.log.
Spot the Bug: Missing break in switch Statement (Fall-through)
Tap or click on the exact line below that contains the error:
Click any code lineconst role = "student";let accessLevel = ""; switch (role) { case "student": accessLevel = "Read Only"; // Missing break! case "admin": accessLevel = "Full Access"; break;}console.log("Access Level:", accessLevel); // Prints: Full Access! (Dangerous bug)Senior Developer Forensic Analysis:
Without a break statement, JavaScript execution falls through to subsequent case clauses regardless of whether they match.
📝Independent Practice: Assignment
📄 fee-engine.htmlUniversity Traffic Light / Fee Discount Engine
- •Create day-23/index.html with interactive conditional logic.
- •Implement an enrollment fee discount engine based on student category (General: 0%, OBC: 10%, SC/ST: 25%).
- •Add input validation ensuring scores fall strictly between 0 and 100.
- •Use console.log to present a structured receipt summary.
Open Visual Studio Code on your PC (code .), create fee-engine.html, paste this complete step-by-step verified code, test in your browser, and push to your GitHub repo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BCA Day 23 - University Fee Discount Engine</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Segoe UI', Tahoma, sans-serif;
background: #0b1120;
color: white;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.card {
background: #1e293b;
border: 1px solid #334155;
border-radius: 16px;
padding: 28px;
max-width: 480px;
width: 100%;
}
h1 { font-size: 20px; color: #38bdf8; margin-bottom: 12px; }
.receipt {
background: #0f172a;
border: 1px dashed #334155;
padding: 16px;
border-radius: 8px;
font-family: monospace;
font-size: 13px;
color: #38bdf8;
line-height: 1.8;
}
</style>
</head>
<body>
<div class="card">
<h1>BCA Fee Discount Engine</h1>
<div class="receipt" id="receipt">Generating fee structure receipt...</div>
</div>
<script>
const standardSemesterFee = 7500; // in INR
const studentCategory = "OBC"; // "General", "OBC", "SC", "ST"
const meritScore = 85; // 0 to 100
let discountPercentage = 0;
// Switch case for category concession
switch (studentCategory.toUpperCase()) {
case "SC":
case "ST":
discountPercentage = 25;
break;
case "OBC":
discountPercentage = 10;
break;
case "GENERAL":
default:
discountPercentage = 0;
break;
}
// Additional merit bonus (if meritScore >= 80, add extra 5%)
if (meritScore >= 80 && meritScore <= 100) {
discountPercentage += 5;
}
const discountAmount = (standardSemesterFee * discountPercentage) / 100;
const finalFeePayable = standardSemesterFee - discountAmount;
const receiptText = `==================================
IGNOU BCA SEMESTER 1 FEE RECEIPT
==================================
Base Semester Fee : ₹${standardSemesterFee}
Student Category : ${studentCategory}
Merit Score : ${meritScore}/100
Total Discount : ${discountPercentage}%
Discount Amount : -₹${discountAmount}
----------------------------------
Final Fee Payable : ₹${finalFeePayable}
==================================`;
console.log(receiptText);
document.getElementById("receipt").innerHTML = receiptText.replace(/\n/g, "<br>").replace(/ /g, " ");
</script>
</body>
</html>🎓4. Viva Check: Mandatory Conceptual Test
Which of the following values is NOT falsy in JavaScript?
5. Mandatory Step: Push to GitHub to Unlock Next Lesson
Target Repo: html-css-projects
Exact GitHub Setup Guide & Expected Structure
Day 23 RequirementsFollow these exact folder and file names to prevent verification errors.
index.html: Avoid spaces or custom names like Alan Turing..html or Index.HTML. Linux/GitHub servers are strictly case-sensitive.day-23/ for today so you don't overwrite previous days.main.You are welcome to read all notes, inspect code snippets, and practice all exercises of Day 23 freely! To officially submit your GitHub repository and unlock subsequent days in your portfolio, please complete Day 22: JavaScript Operators: Arithmetic, Strict Equality (===) & Logical Conditions first.
Complete Day 22 First