Step 1: Learn the basics›Things to Know in C++/Java/Python or any language
Switch Case & The Geometry Dispatcher
EasyFunction: switchCase()
ASCI Mission Breakdown • Simple as Hell
"Dispatch calculation to Circle Area or Rectangle Area based on the choice code."
Real-World Metaphor:
Imagine a coffee vending machine. Button 1 brews an Espresso (uses 1 bean measure), while Button 2 mixes a Cappuccino (uses coffee plus milk). Depending on the button pressed, the machine routes to a specific dispenser.
Interactive Visual WalkthroughFLOW-DIAGRAM
Step 1 / 3
Choice1
ShapeCircle
Radius5
Evaluating
1. Read Choice Code
Received choice = 1 with radius r = 5.
How to Think About This (Mental Model)
Inspect choice parameter (1 or 2).
If choice === 1: extract radius r, compute Math.PI * r * r.
If choice === 2: extract length l and breadth b, compute l * b.
Return the resulting area.
### The Mission
You are writing software for an automated drafting plotter. The user sends a choice code indicating which geometric figure they want calculated:
- Choice **1**: Calculate the area of a **Circle** given its radius `r`: Area = `π * r * r`.
- Choice **2**: Calculate the area of a **Rectangle** given length `l` and breadth `b`: Area = `l * b`.
Return the exact calculated area for the requested figure.
Examples
Example 1
Input: x = 10, y = 20
Output: 30
Explanation: Returns the processed result of the inputs.
Constraints
-10^5 <= x, y <= 10^5
Topic Tags:
Learn the basicsThings to Know in C++/Java/Python or any languageswitchCase