Lesson 9 of 34

switch: பல மதிப்புகளில் ஒன்றைத் தேர்வு செய்தல்

8 min 30 XP

ஒரு variable-ன் மதிப்பைப் பொறுத்து பல வழிகளில் ஒன்றைத் தேர்வு செய்ய switch பயன்படுகிறது. ஒவ்வொரு case-ன் முடிவிலும் break வேண்டும், இல்லையெனில் அடுத்த case-ம் இயங்கும். எதுவும் பொருந்தவில்லை என்றால் default இயங்கும்.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

switch, String மற்றும் char மதிப்புகளுடனும் வேலை செய்யும். கீழே ஒரு சிறிய calculator.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Challenge

+30 XP

இரண்டு எண்கள் மற்றும் ஒரு operator (+ - * /) படித்து விடையை print செய்யுங்கள். வேறு operator வந்தால் "Invalid" என்று print செய்யுங்கள். Input: 8 * 5 → Output: 40

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.