when to use else if?

<p>why in the world would you use "else if" ever when you have the simple "if"? :/</p>

<p>If you use an if statement and the condition, like a comparison for example, is not true, then you could use else if to make another comparison.</p>

<p>For an example of this: check Sample Question 4 in the AP Course Description:</p>

<p><a href=“Supporting Students from Day One to Exam Day – AP Central | College Board”>Supporting Students from Day One to Exam Day – AP Central | College Board;

<p>if (score >= 93)
grade = “A”;
else if (score >= 84)
grade = “B”;
else if (score >= 75)
grade = “C”;
else
grade = “F”;</p>

<p>compared to</p>

<p>if (score > 93)
grade = “A”;
if (score >= 84 && score <= 92)
grade = “B”;
if (score >= 75 && score <= 83)
grade = “C”;
if (score < 75)
grade = “F”;</p>

<p>which one seems clearer to you?</p>

<p>hmm I see a point now…</p>

<p>btw, would this work </p>

<p>if (93 >= score >= 84)
grade = “B”;</p>

<p>or would it throw an error?</p>

<p>That would cause an error.</p>

<p>umm why? 10cahr</p>

<p>If you want to do that, split it up like this:</p>

<p>if(score <= 93 && score >= 84)
grade = “B”;</p>

<p>if(score <= 93 && score >= 84)
grade = “B”;
btw, && = and
|| = or</p>