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)

Section A

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.

๐Ÿ‡ฎ๐Ÿ‡ณ IRCTC๐Ÿ‡ฎ๐Ÿ‡ณ SBI ATM๐Ÿ‡ฎ๐Ÿ‡ณ Paytm๐Ÿ‡ฎ๐Ÿ‡ณ PhonePe๐Ÿ‡ฎ๐Ÿ‡ณ Razorpay๐Ÿ‡ฎ๐Ÿ‡ณ Zomato
Indian Railways runs 13,000+ trains daily and uses conditional logic in every subsystem โ€” from fare calculation to seat allocation, from waitlist priority to dynamic pricing on Tatkal tickets. The entire reservation system is built on billions of if-else and switch-case decisions executing every second.
Section B

Learning Outcomes โ€” Bloom's Taxonomy Mapped (12 Outcomes)

Bloom's LevelLearning Outcome
๐Ÿ”ต RememberLO-1: List the syntax of if, if-else, switch, and switch expression statements in Java
๐Ÿ”ต RememberLO-2: Define the purpose of break, default, and yield keywords in switch constructs
๐Ÿ”ต UnderstandLO-3: Explain the difference between nested if-else and chained (else-if ladder) conditional structures
๐Ÿ”ต UnderstandLO-4: Describe how switch fall-through works and why it causes bugs in traditional switch statements
๐ŸŸข ApplyLO-5: Write a GradeCalculator program using nested if-else to assign letter grades from marks
๐ŸŸข ApplyLO-6: Implement an IRCTC Fare Calculator using both if-else chains and switch-case statements
๐ŸŸข ApplyLO-7: Build a SimpleATM menu-driven program using traditional switch-case with break
๐ŸŸ  AnalyzeLO-8: Compare traditional switch (with break) vs enhanced switch (Java 14+ arrow syntax) for readability and safety
๐ŸŸ  AnalyzeLO-9: Determine when to use if-else vs switch-case based on the type and number of conditions
๐ŸŸ  EvaluateLO-10: Evaluate switch fall-through traps in MCQ scenarios and predict output correctly
๐ŸŸ  EvaluateLO-11: Assess which conditional pattern best solves a given Indian industry problem scenario
๐Ÿ”ด CreateLO-12: Design a complete rule-based fare/discount calculator using multiple conditional constructs for a real-world Indian business scenario