Programming in Java
Unit 4: Conditional Statements
From simple if-else decisions to complex switch expressions โ master every conditional construct in Java and build real-world decision engines.
โฑ๏ธ 4 hrs theory + 3 hrs lab | ๐ฐ Earning Potential: โน5Kโโน15K/month | ๐ 30 MCQs (Bloom's Mapped)
๐ผ Jobs this unlocks: Java Developer (โน4โ8 LPA) | Backend Engineer (โน6โ12 LPA) | Automation Engineer (โน5โ10 LPA)
Opening Hook โ The Code Behind Every IRCTC Ticket
๐ How IRCTC Calculates Your Railway Fare in Milliseconds
Every time you book a train ticket on IRCTC, a fare engine fires up behind the scenes. It checks your travel class โ 1A (First AC), 2A (Second AC), 3A (Third AC), SL (Sleeper), or General โ and applies the right fare formula. A DelhiโMumbai journey costs โน4,825 in 1A, โน2,770 in 2A, โน1,950 in 3A, โน680 in SL, and โน350 in General. Same route, same train, five completely different prices.
This isn't a complex AI model โ it's a switch-case statement. The system checks your selected class, jumps to the matching case, calculates the fare, and returns the result. No unnecessary comparisons, no wasted CPU cycles. Indian Railways processes 25+ million ticket requests on peak Tatkal days โ and at the heart of it all is conditional logic.
Every ticket you book triggers a switch-case. Every ATM withdrawal runs through an if-else chain. Every app login checks conditions. Conditional statements aren't just textbook theory โ they're the backbone of every piece of software you use daily.
Learning Outcomes โ Bloom's Taxonomy Mapped (12 Outcomes)
| Bloom's Level | Learning Outcome |
|---|---|
| ๐ต Remember | LO-1: List the syntax of if, if-else, switch, and switch expression statements in Java |
| ๐ต Remember | LO-2: Define the purpose of break, default, and yield keywords in switch constructs |
| ๐ต Understand | LO-3: Explain the difference between nested if-else and chained (else-if ladder) conditional structures |
| ๐ต Understand | LO-4: Describe how switch fall-through works and why it causes bugs in traditional switch statements |
| ๐ข Apply | LO-5: Write a GradeCalculator program using nested if-else to assign letter grades from marks |
| ๐ข Apply | LO-6: Implement an IRCTC Fare Calculator using both if-else chains and switch-case statements |
| ๐ข Apply | LO-7: Build a SimpleATM menu-driven program using traditional switch-case with break |
| ๐ Analyze | LO-8: Compare traditional switch (with break) vs enhanced switch (Java 14+ arrow syntax) for readability and safety |
| ๐ Analyze | LO-9: Determine when to use if-else vs switch-case based on the type and number of conditions |
| ๐ Evaluate | LO-10: Evaluate switch fall-through traps in MCQ scenarios and predict output correctly |
| ๐ Evaluate | LO-11: Assess which conditional pattern best solves a given Indian industry problem scenario |
| ๐ด Create | LO-12: Design a complete rule-based fare/discount calculator using multiple conditional constructs for a real-world Indian business scenario |