Lesson 7 of 34

else if: பல வழிகள்else if: Many Choices

8 min 25 XP

இரண்டுக்கு மேற்பட்ட வழிகள் இருந்தால் else if பயன்படுத்துங்கள். Java மேலிருந்து கீழாகச் சோதிக்கும்; முதலில் true ஆகும் பகுதி மட்டுமே இயங்கும்.

Use else if when there are more than two choices. Java checks from top to bottom and runs only the first block whose condition is true.

Example: edit me and press Run

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

வரிசை முக்கியம்! பெரிய மதிப்பை முதலில் சோதியுங்கள். temp >= 15 முதலில் இருந்தால் 40-ம் "Pleasant" என்று வரும்.

Order matters! Check the biggest range first. If temp >= 15 came first, even 40 would print "Pleasant".

Challenge

+25 XP

மதிப்பெண்ணைப் படித்து grade print செய்யுங்கள்: 90+ → A, 75–89 → B, 50–74 → C, 50-க்குக் கீழ் → D

Read a mark and print its grade: 90+ → A, 75–89 → B, 50–74 → C, below 50 → D

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