<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Arya</id>
		<title>Script | Spoken-Tutorial - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Arya"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php/Special:Contributions/Arya"/>
		<updated>2026-05-24T11:35:29Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php/Java/C2/Switch-Case/English</id>
		<title>Java/C2/Switch-Case/English</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php/Java/C2/Switch-Case/English"/>
				<updated>2012-12-07T11:23:55Z</updated>
		
		<summary type="html">&lt;p&gt;Arya: Created page with ''''Title of script''': Switch Case in Java  '''Author''': TalentSprint  '''Keywords: '''case, switch, conditions, video tutorial    {| style=&amp;quot;border-spacing:0;&amp;quot; | style=&amp;quot;border:0…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Title of script''': Switch Case in Java&lt;br /&gt;
&lt;br /&gt;
'''Author''': TalentSprint&lt;br /&gt;
&lt;br /&gt;
'''Keywords: '''case, switch, conditions, video tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border-spacing:0;&amp;quot;&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Visual Cue '''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Description'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 1&lt;br /&gt;
&lt;br /&gt;
'''Welcome'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Welcome to the spoken tutorial on '''Switch case in Java'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 2&lt;br /&gt;
&lt;br /&gt;
'''Learning Outcomes'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| In this tutorial, you will learn how to use the '''switch case construct in Java'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 3&lt;br /&gt;
&lt;br /&gt;
'''Tools Used'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| For this tutorial we are using &lt;br /&gt;
&lt;br /&gt;
* '''Ubuntu 11.10'''&lt;br /&gt;
* '''JDK 1.6''' and &lt;br /&gt;
* '''Eclipse 3.7.0'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 4&lt;br /&gt;
&lt;br /&gt;
'''Prerequisites'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| For this tutorial, you should have knowledge of if else statement in Java.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If not, please go through the tutorials on these topics available at our website [http://spoken-tuitorial.org/ http][http://spoken-tuitorial.org/ ://][http://spoken-tuitorial.org/ spoken][http://spoken-tuitorial.org/ -][http://spoken-tuitorial.org/ tutorial][http://spoken-tuitorial.org/ .][http://spoken-tuitorial.org/ org]&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 5&lt;br /&gt;
&lt;br /&gt;
'''switch case'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| The switch case is used to perform actions based on the value of a variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the syntax for a '''switch case statement'''. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us use it now.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Minimize Slides and open Eclipse&lt;br /&gt;
&lt;br /&gt;
Eclipse should contain the following code&lt;br /&gt;
&lt;br /&gt;
'''public class SwitchCaseDemo{'''&lt;br /&gt;
&lt;br /&gt;
'''public static void main(String&amp;lt;nowiki&amp;gt;[] &amp;lt;/nowiki&amp;gt;args){'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| I already have '''Eclipse''' opened.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I have created a '''class''' named '''SwitchCaseDemo.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us add some variables.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Inside the main, type&lt;br /&gt;
&lt;br /&gt;
'''int day = 3;'''&lt;br /&gt;
&lt;br /&gt;
'''String dName = “”&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Highlight day and dName when you explain.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Inside the main, we will create a '''variable day''' of type '''int'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So type''' int day '''and we can give it a value '''equal to''' '''3'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, let us create a '''variable dName''' of type '''String.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then initialize it to null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here '''dName '''is a '''variable '''to hold the names of the days of a week.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''day''' stores the '''day number'''.&lt;br /&gt;
&lt;br /&gt;
Now, we will type the '''switch case statement.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So type '''switch '''within brackets''' day , '''then open curly brackets... &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Highlight '''switch(day)'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| This statement defines which variable is under consideration for the cases.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''switch(day) {'''&lt;br /&gt;
&lt;br /&gt;
'''case 0:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Sunday”;'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Next line '''type '''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''case 0 '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''dName '''''equal to within double quotes''''' Sunday '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
Then type '''break '''''semicolon.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This statement says that if the value of day is 0, the value of '''dName''' must be set to '''Sunday.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that a '''break''' statement must be used at the end of each case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
without the break statement, the switch-case functions in a complex fashion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It will be explained in subsequent part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| '''switch(day) {'''&lt;br /&gt;
&lt;br /&gt;
'''case 0:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Sunday”;'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''case 1:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Monday”;'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''case 2:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Tuesday”;'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''case 3:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Wednesday”;'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''case 4:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Thursday”;'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''case 5:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Friday”;'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''case 6:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Saturday”;'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Similarly, let us type the remaining cases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''case 1 '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''dName '''''equal to within double quotes''''' Monday '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''break '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''case 2 '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''dName '''''equal to within double quotes''''' Tuesday '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''break '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''case 3 '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''dName '''''equal to within double quotes''''' Wednesday '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''break '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''case 4 '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''dName '''''equal to within double quotes''''' Thursday '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''break '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''case 5 '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''dName '''''equal to within double quotes''''' Friday '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''break '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''case 5 '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''dName '''''equal to within double quotes''''' Saturday '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
'''break '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
Then close the brackets.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us now add a print statement and see the code in action.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Type '''System.out.println(dName);'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''save''' and '''run'''. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Point to output&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Type '''System '''''dot '''''out '''''dot '''''println '''''within brackets '''''dName '''''semicolon.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Save''' and run.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As we can see, the output is '''Wednesday''' corresponding to the case '''3.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us change the value of day and see the result&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Change '''day = 3''' to '''day = 0'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''save''' and''' run'''. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Point to output&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Change '''3''' to '''0'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Save and Run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As we can see, the output is '''Sunday''' corresponding to the case '''0'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now what if there is no case corresponding to the value. Let us see&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Change '''day = 0''' to '''day = -1'''&lt;br /&gt;
&lt;br /&gt;
save and run. Point to output&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| As we can see, there is no output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But it would be better if we could have a case for all other values.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
That is done by using the '''default''' keyword.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| After the last case, type this&lt;br /&gt;
&lt;br /&gt;
'''default:'''&lt;br /&gt;
&lt;br /&gt;
'''dName = “Wrong Choice”'''&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''save''' and '''run'''. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Point to output&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| After the last case, type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''default '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''dName '''''equal to within double quotes '''''Wrong Choice'''&lt;br /&gt;
&lt;br /&gt;
'''break '''''semicolon''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that we simply use the keyword '''default''' .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We do not say '''case default.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us now run the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As we can see, the default case is executed and the required message is printed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us try with another random value.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Change '''day = -1''' to '''day = 15'''&lt;br /&gt;
&lt;br /&gt;
save and run. Point to output&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Change '''-1''' to '''15'''&lt;br /&gt;
&lt;br /&gt;
As we can see, again the default case is executed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Now let us see what happens if we remove the break statement.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Change '''day = 15''' to '''day = 4'''&lt;br /&gt;
&lt;br /&gt;
Remove the '''break in case 4''' statement there&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us change '''day = 15''' to '''day = 4'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And remove the corresponding break statement for '''day&amp;lt;nowiki&amp;gt;=4&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Save and run&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| '''Point to output'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Although the case is 4, we get the output as''' Friday''' and not '''Thursday.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| '''Highlight case 4 and case 5'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| This is because of the way switch case works. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First the value of day is compared with 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then with 1 and then with 2 and so on with all the possible cases.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| When a match is found, it executes all the case from the match onwards.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In our case, it executed case 5 after case 4 .&lt;br /&gt;
&lt;br /&gt;
Then it stops because of the break statement in case 5.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| To avoid that, we need to add a '''break''' statement in each case.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Type in case 4&lt;br /&gt;
&lt;br /&gt;
'''break&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us now add the break statement we removed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Type break '''''semicolon.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let us run the code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Save and run. Point to output&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| As we can see, now only '''case 4''' is executed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As a rule, remember to use a '''break''' statement in every case to avoid errors.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Minimize the '''Eclipse''' window and switch to slides.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Slide 6&lt;br /&gt;
&lt;br /&gt;
'''Summary'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| We have come to the end of this tutorial. &lt;br /&gt;
&lt;br /&gt;
In this tutorial we have learnt how to '''use switch case construct''' and '''how to use break statement.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 7'''Assignment'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Write a program that has a name and gender and a switch case statement that prints “Hello Mr....” for males and “Hello Ms...” for females.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 8'''About the Spoken Tutorial Project'''&lt;br /&gt;
&lt;br /&gt;
* Watch the video available at[http://spoken-tutorial.org/What_is_a_Spoken_Tutorial  ][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial http][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial ://][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial spoken][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial -][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial tutorial][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial .][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial org][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial /][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial What][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial is][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial a][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial Spoken][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial Tutorial]&lt;br /&gt;
&lt;br /&gt;
* It summarises the Spoken Tutorial project&lt;br /&gt;
&lt;br /&gt;
* If you do not have good bandwidth, you can download and watch it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| To know more about the '''Spoken Tutorial''' project, watch the video available at the following link, that summarises the project.Alternatively, you can download and watch it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 9'''Spoken Tutorial Workshops'''The Spoken Tutorial Project Team&lt;br /&gt;
&lt;br /&gt;
* Conducts workshops using spoken tutorials&lt;br /&gt;
&lt;br /&gt;
* Gives certificates for those who pass an online test&lt;br /&gt;
&lt;br /&gt;
* For more details, please write to [mailto:contact@spoken-tutorial.org contact][mailto:contact@spoken-tutorial.org @][mailto:contact@spoken-tutorial.org spoken][mailto:contact@spoken-tutorial.org -][mailto:contact@spoken-tutorial.org tutorial][mailto:contact@spoken-tutorial.org .][mailto:contact@spoken-tutorial.org org]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| The Spoken Tutorial Project Team. Conducts workshops using '''spoken tutorials''' and gives certificates for those who pass an online test. For more details, please write to '''contact AT spoken HYPHEN tutorial DOT org.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 10'''Acknowledgement'''&lt;br /&gt;
&lt;br /&gt;
* Spoken Tutorial Project is a part of the Talk to a Teacher project&lt;br /&gt;
&lt;br /&gt;
* It is supported by the National Mission on Education through ICT, MHRD, Government of India&lt;br /&gt;
&lt;br /&gt;
* More information on this Mission is available at&lt;br /&gt;
&lt;br /&gt;
* [http://spoken-tutorial.org/NMEICT-Intro http][http://spoken-tutorial.org/NMEICT-Intro ://][http://spoken-tutorial.org/NMEICT-Intro spoken][http://spoken-tutorial.org/NMEICT-Intro -][http://spoken-tutorial.org/NMEICT-Intro tutorial][http://spoken-tutorial.org/NMEICT-Intro .][http://spoken-tutorial.org/NMEICT-Intro org][http://spoken-tutorial.org/NMEICT-Intro /][http://spoken-tutorial.org/NMEICT-Intro NMEICT][http://spoken-tutorial.org/NMEICT-Intro -][http://spoken-tutorial.org/NMEICT-Intro Intro]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Spoken Tutorial '''Project is a part of the '''Talk to a Teacher''' project and is supported by the '''National Mission on Education through ICT, MHRD, Government of India. '''More information on this Mission is available at '''spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 11'''About the contributor'''&lt;br /&gt;
&lt;br /&gt;
* This tutorial has been contributed by '''TalentSprint'''&lt;br /&gt;
* '''www.talentsprint.com'''&lt;br /&gt;
&lt;br /&gt;
* Thanks for joining&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| This tutorial has been contributed by '''TalentSprint'''. Thanks for joining.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Arya</name></author>	</entry>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php/Java/C2/Nested-if/English</id>
		<title>Java/C2/Nested-if/English</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php/Java/C2/Nested-if/English"/>
				<updated>2012-12-07T11:19:10Z</updated>
		
		<summary type="html">&lt;p&gt;Arya: Created page with ''''Author : '''TalentSprint  '''Script Title : '''Nested-If and Ternary Operator  '''Keywords : '''If else conditional statements, Ternary operator, nested-if, video tutorial    …'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Author : '''TalentSprint&lt;br /&gt;
&lt;br /&gt;
'''Script Title : '''Nested-If and Ternary Operator&lt;br /&gt;
&lt;br /&gt;
'''Keywords : '''If else conditional statements, Ternary operator, nested-if, video tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border-spacing:0;&amp;quot;&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Visual Clue'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Description'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 1&lt;br /&gt;
&lt;br /&gt;
'''Welcome'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Welcome to the spoken tutorial on '''Nested-If and Ternary Operator '''in java'''.''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 2&lt;br /&gt;
&lt;br /&gt;
'''Learning Objectives '''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| By the end of this tutorial you should be able to:&lt;br /&gt;
&lt;br /&gt;
* Explain Nested-If Statements and Ternary operators.&lt;br /&gt;
* Use them in a Java program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 3 &lt;br /&gt;
&lt;br /&gt;
'''Tools Used'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| For this tutorial we are using:&lt;br /&gt;
&lt;br /&gt;
'''Ubuntu 11.10,'''&lt;br /&gt;
&lt;br /&gt;
'''JDK 1.6,'''and&lt;br /&gt;
&lt;br /&gt;
'''Eclipse 3.7.0'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 4&lt;br /&gt;
&lt;br /&gt;
'''Pre-requisites '''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| To follow this tutorial, you should know,&lt;br /&gt;
&lt;br /&gt;
- the usage of relational and logical operators.&lt;br /&gt;
&lt;br /&gt;
- '''if...else''' control flow statements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If not, for relevant tutorial please visit our website which is as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 5&lt;br /&gt;
&lt;br /&gt;
'''Nested-If statements'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| An '''if''' statement within another '''if '''statement is called a '''nested-if '''statement.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 6&lt;br /&gt;
&lt;br /&gt;
'''Syntax for Nested-If Statement'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Point to the line of code as you explain.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (condition1) { &lt;br /&gt;
&lt;br /&gt;
if (condition2) {&lt;br /&gt;
&lt;br /&gt;
Statement or block 1&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
else {&lt;br /&gt;
&lt;br /&gt;
Statement or block 2&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
else {&lt;br /&gt;
&lt;br /&gt;
Statement or block 3&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us look at the syntax for writing the '''Nested-If statement'''.&lt;br /&gt;
&lt;br /&gt;
In this case, if condition 1 is true, then the program checks for condition 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Condition 2 is given using another If statement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If condition 2 is true, then the program executes Statement or block 1.&lt;br /&gt;
&lt;br /&gt;
Else, it executes Statement or block 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If condition 1 is false, then the program will not check condition2.&lt;br /&gt;
&lt;br /&gt;
Instead will directly jump to its else statement i.e. block 3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Let us try and example to understand that better&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| '''Point to the code'''&lt;br /&gt;
&lt;br /&gt;
{ Minimize slides and open Eclise. It should contain the following }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''public class NestedIfDemo {'''&lt;br /&gt;
&lt;br /&gt;
'''public static void main(String args&amp;lt;nowiki&amp;gt;[]) {&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We have the eclipse IDE and the skeleton required for the rest of the code. &lt;br /&gt;
&lt;br /&gt;
We have created a class '''NesedIfDemo''' and added the main method to it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type &lt;br /&gt;
&lt;br /&gt;
'''int n = -5;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Highlight '''int n = -5;'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We shall check if the given number is a even number or an odd number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But we will also handle negative numbers using a nested-if.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So type &lt;br /&gt;
&lt;br /&gt;
'''int n = minus 5;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have created a variable to store the number.&lt;br /&gt;
&lt;br /&gt;
Now we shall write the if conditions.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type &lt;br /&gt;
&lt;br /&gt;
'''if (n&amp;lt;nowiki&amp;gt; &amp;lt; 0) {&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''System.out.println(“Negative number”);'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''if (n&amp;lt;nowiki&amp;gt; &amp;lt; 0) &amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''''open curly bracket'''''&lt;br /&gt;
&lt;br /&gt;
'''System.out.println(“Negative number”);'''&lt;br /&gt;
&lt;br /&gt;
'''''close curly bracket'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We first see if the number is a negative number.&lt;br /&gt;
&lt;br /&gt;
If yes then we will not check for even and odd.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Then if the number is not a negative, we then check for even and odd.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type after the if statement.&lt;br /&gt;
&lt;br /&gt;
'''else{'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type&lt;br /&gt;
&lt;br /&gt;
'''else {'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now if the execution has come to the else part.&lt;br /&gt;
&lt;br /&gt;
It means that the number is non negative.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we check for odd or even inside this else part.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| inside else, type&lt;br /&gt;
&lt;br /&gt;
'''if (n % 2 == 0) {'''&lt;br /&gt;
&lt;br /&gt;
'''System.out.println(“Even number”);'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
'''else {'''&lt;br /&gt;
&lt;br /&gt;
'''System.out.println(“Odd number”);'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type&lt;br /&gt;
&lt;br /&gt;
'''if (n ''percent'' 2 equalto equalto 0) {'''&lt;br /&gt;
&lt;br /&gt;
'''System.out.println(“Even number”);'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
'''else {'''&lt;br /&gt;
&lt;br /&gt;
'''System.out.println(“Odd number”);'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we make sure that negative numbers are not considered for odd or even check.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Now let us see the code in action.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| '''Save''' and '''Run'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| As we can see, we get the output “negative”.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us try a positive number&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Change n = -5 to n = 5&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Change n = -5 to n = 5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Save''' and''' Run'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Point to the output&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| As we can see, the output is odd as expected. Let us try an even number&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Change n = 5 to n = 10&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Change n = 5 to n = 10.&lt;br /&gt;
&lt;br /&gt;
Save and run.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Point to the output.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| As we can see, the output is “even” as expected.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Highlight the code&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| This process of including an if statement inside another, is called nested-if.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is no limit to the amount of nesting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But it is a good practice to not go beyond 3 levels of nesting.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Remove everything inside the '''Main''' method&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Now we shall look at the ternary operator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First let me clean up the '''Main''' method.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We shall write a program that divides a number by 2. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is a very trivial program but the issue comes in dividing odd numbers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When 7 is divided by 2, we get 3.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But what if we want the result to be rounded off.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Which means, when 7 is divided by 2, we get must 4 and not 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In simple terms, we need the next number.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Let us see how to write such a program.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type &lt;br /&gt;
&lt;br /&gt;
'''int n, nHalf&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type &lt;br /&gt;
&lt;br /&gt;
'''int n, nHalf&amp;lt;nowiki&amp;gt;;&amp;lt;/nowiki&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will store the number in n and the half number in nHalf&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''n = 5;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''if (n % 2 == 0) {'''&lt;br /&gt;
&lt;br /&gt;
'''nHalf = n / 2;'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
'''else {'''&lt;br /&gt;
&lt;br /&gt;
'''nHalf = (n + 1) / 2;'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type&lt;br /&gt;
&lt;br /&gt;
'''n = 5;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''if (n % 2 == 0) {'''&lt;br /&gt;
&lt;br /&gt;
'''nHalf = n / 2;'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
'''else {'''&lt;br /&gt;
&lt;br /&gt;
'''nHalf = (n + 1) / 2;'''&lt;br /&gt;
&lt;br /&gt;
'''}'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We check if the number is even or odd and do the division accordingly.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''System.out.println(nHalf);'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Let us add a print statement to see the program in action.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''System.out.println(nHalf);'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| '''Save''' and '''Run'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Point to the output.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| '''Save''' and '''Run'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As we can see, our objective is met.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Point to the code.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| But if we notice, all we are doing is, setting the value of a variable depending on a condition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is more syntax than logic in our program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is when ternary operator makes code simpler.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| {Switch to Slides}&lt;br /&gt;
&lt;br /&gt;
Slide 7&lt;br /&gt;
&lt;br /&gt;
Ternary Operator.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| A conditional operator providing results similar to nested-if.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Provides a short syntax and is denoted by a question mark.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Takes three operands at a time.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 8&lt;br /&gt;
&lt;br /&gt;
'''Point to the syntax'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Syntax of Ternary Operator'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Syntax:&lt;br /&gt;
&lt;br /&gt;
Result = Expression '''?''' Operand 1''' :''' Operand 2&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us learn about the syntax of Ternary Operator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The expression is the condition that has to be checked.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operand 1 is the value of the variable Result if the condition is true.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operand 2 is the value if the condition is false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us use it in our program.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| {Switch to eclipse}&lt;br /&gt;
&lt;br /&gt;
Remove the if-else statement&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| First let us remove the if-else statement.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''nHalf = n % 2 == 0 ? n / 2 : (n + 1) / 2'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''nHalf = n % 2 == 0 ? n / 2 : (n + 1) / 2'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This statement reads,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if n is even, nHalf is n by 2.&lt;br /&gt;
&lt;br /&gt;
Otherwise, it is n plus 1 by 2.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| '''Save''' and '''Run'''.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Let us now see it in action.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Save''' and '''Run'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Point to the output.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| As we can see, the output is as expected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This way, ternary operator reduces clutter in the code and improves readability.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 9&lt;br /&gt;
&lt;br /&gt;
'''Summary'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| We have come to the end of this tutorial. &lt;br /&gt;
&lt;br /&gt;
In this tutorial we have learnt:&lt;br /&gt;
&lt;br /&gt;
* About Nested-If Statements and Ternary Operator&lt;br /&gt;
* Usage of Nested-If Statements and Ternary Operator in a Java program&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 10&lt;br /&gt;
&lt;br /&gt;
'''Assignment'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Now take an assignment on &lt;br /&gt;
&lt;br /&gt;
Nested-If and Ternary operator. Write java program for the following.&lt;br /&gt;
&lt;br /&gt;
* Check whether a number is even and also a multiple of 11 using nested-if.&lt;br /&gt;
* Identify the largest number among the two given numbers using Ternary operator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 11&lt;br /&gt;
&lt;br /&gt;
'''About the Spoken Tutorial Project'''&lt;br /&gt;
&lt;br /&gt;
* Watch the video available at[http://spoken-tutorial.org/What_is_a_Spoken_Tutorial  ][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial http][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial ://][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial spoken][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial -][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial tutorial][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial .][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial org][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial /][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial What][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial is][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial a][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial Spoken][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial Tutorial]&lt;br /&gt;
&lt;br /&gt;
* It summarizes the Spoken Tutorial project&lt;br /&gt;
&lt;br /&gt;
If you do not have good bandwidth, you can download and watch it&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| To know more about the '''Spoken Tutorial''' project, watch the video available at the following link. It summarizes the project.If you do not have good bandwidth, you can download and watch it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 12&lt;br /&gt;
&lt;br /&gt;
'''Spoken Tutorial Workshops'''&lt;br /&gt;
&lt;br /&gt;
The Spoken Tutorial Project Team&lt;br /&gt;
&lt;br /&gt;
* Conducts workshops using spoken tutorials&lt;br /&gt;
&lt;br /&gt;
* Gives certificates for those who pass an online test&lt;br /&gt;
&lt;br /&gt;
* For more details, please write to [mailto:contact@spoken-tutorial.org contact][mailto:contact@spoken-tutorial.org @][mailto:contact@spoken-tutorial.org spoken][mailto:contact@spoken-tutorial.org -][mailto:contact@spoken-tutorial.org tutorial][mailto:contact@spoken-tutorial.org .][mailto:contact@spoken-tutorial.org org]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| The Spoken Tutorial Project Team. Conducts workshops using '''spoken tutorials''' and gives certificates for those who pass an online test. For more details, please write to '''contact AT spoken HYPHEN tutorial DOT org.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 13&lt;br /&gt;
&lt;br /&gt;
'''Acknowledgement'''&lt;br /&gt;
&lt;br /&gt;
* Spoken Tutorial Project is a part of the Talk to a Teacher project&lt;br /&gt;
&lt;br /&gt;
* It is supported by the National Mission on Education through ICT, MHRD, Government of India&lt;br /&gt;
&lt;br /&gt;
* More information on this Mission is available at&lt;br /&gt;
&lt;br /&gt;
* [http://spoken-tutorial.org/NMEICT-Intro http][http://spoken-tutorial.org/NMEICT-Intro ://][http://spoken-tutorial.org/NMEICT-Intro spoken][http://spoken-tutorial.org/NMEICT-Intro -][http://spoken-tutorial.org/NMEICT-Intro tutorial][http://spoken-tutorial.org/NMEICT-Intro .][http://spoken-tutorial.org/NMEICT-Intro org][http://spoken-tutorial.org/NMEICT-Intro /][http://spoken-tutorial.org/NMEICT-Intro NMEICT][http://spoken-tutorial.org/NMEICT-Intro -][http://spoken-tutorial.org/NMEICT-Intro Intro]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Spoken Tutorial '''Project is a part of the '''Talk to a Teacher''' project and is supported by the '''National Mission on Education through ICT, MHRD, Government of India. '''More information on this Mission is available at '''spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Slide 14&lt;br /&gt;
&lt;br /&gt;
'''About the contributor'''&lt;br /&gt;
&lt;br /&gt;
* This tutorial has been contributed by '''TalentSprint'''&lt;br /&gt;
* '''www.talentsprint.com'''&lt;br /&gt;
&lt;br /&gt;
Thanks for joining &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| This tutorial has been contributed by '''TalentSprint'''. &lt;br /&gt;
&lt;br /&gt;
Thanks for joining.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Arya</name></author>	</entry>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php/Java/C2/if-else/English</id>
		<title>Java/C2/if-else/English</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php/Java/C2/if-else/English"/>
				<updated>2012-12-07T11:11:37Z</updated>
		
		<summary type="html">&lt;p&gt;Arya: Created page with ''''Author : '''TalentSprint  '''ScriptTitle: '''If Else Construct  '''Keywords: '''if, else, conditional statements, if, if else, if else if, Eclipse, video tutorial    {| style=…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Author : '''TalentSprint&lt;br /&gt;
&lt;br /&gt;
'''ScriptTitle: '''If Else Construct&lt;br /&gt;
&lt;br /&gt;
'''Keywords: '''if, else, conditional statements, if, if else, if else if, Eclipse, video tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border-spacing:0;&amp;quot;&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Visual cue''' &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Narration'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 1 '''&lt;br /&gt;
&lt;br /&gt;
'''Welcome'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Welcome to the spoken tutorial on '''If else constructs '''in java. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 2'''&lt;br /&gt;
&lt;br /&gt;
'''Learning Objectives'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| In this tutorial we will learn:&lt;br /&gt;
&lt;br /&gt;
* About conditional statements&lt;br /&gt;
* The types of conditional statements and&lt;br /&gt;
* How to use conditional statements in Java programs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 3'''&lt;br /&gt;
&lt;br /&gt;
'''Tools Used'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| For this tutorial we are using:&lt;br /&gt;
&lt;br /&gt;
Ubuntu 11.10&lt;br /&gt;
&lt;br /&gt;
JDK 1.6 &lt;br /&gt;
&lt;br /&gt;
Eclipse 3.7 &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 4'''&lt;br /&gt;
&lt;br /&gt;
'''Pre-requisites''' &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| To follow this tutorial you should have knowledge of using &lt;br /&gt;
&lt;br /&gt;
* '''Arithmetic''', '''Relational''' and '''Logical''' '''operators''' in '''Java'''&lt;br /&gt;
&lt;br /&gt;
If not, for relevant tutorials please visit our website which is as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 5'''&lt;br /&gt;
&lt;br /&gt;
'''Conditional Statements'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| You may have to perform different actions for different decisions in your code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In such cases you can use conditional statements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A conditional&amp;amp;nbsp;statement&amp;amp;nbsp;helps to control the flow of execution of a program. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 6'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Types of Conditional Statements'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| In Java we have the following conditional statements:&lt;br /&gt;
&lt;br /&gt;
* If statement&amp;amp;nbsp;&lt;br /&gt;
* If...Else statement&amp;amp;nbsp;&lt;br /&gt;
* If...Else if statement&amp;amp;nbsp;&lt;br /&gt;
* Nested If statement&lt;br /&gt;
* Switch statement&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we will learn about '''If, If...Else and If...Else If statements''' in detail.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 7'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''If Statement'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''If statement&amp;amp;nbsp;'''is used to execute a block of statements based on a condition. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is called a '''single conditional statement.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is also called '''branching''' or '''decision making statement. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 8'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Syntax for If statement&amp;amp;nbsp;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (condition) &lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
code_block&amp;lt;nowiki&amp;gt;; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
// end of if construct &lt;br /&gt;
&lt;br /&gt;
// program continues here''' '''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us look at the syntax for writing '''if statement'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the '''if statement, '''if the condition is '''true,''' the block is executed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the condition is '''false, '''the block is skipped and not executed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Example of If statement&amp;amp;nbsp;''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Minimize the slide and in the Eclipse tool, type the program according to the explanation)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class Person&lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
public static void main(String args&amp;lt;nowiki&amp;gt;[]) {&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int age&amp;lt;nowiki&amp;gt;=20; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if(age&amp;lt;nowiki&amp;gt;&amp;lt;21) { &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
System.out.println(&amp;quot;The person is Minor&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Highlight when you explain&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Highlight '''{}'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us look at an example to understand how the '''If Statement''' can be used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us switch to '''eclipse.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will write a program to identify whether a person is '''Minor'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I have already created a class '''Person.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, inside the main method let us declare a variable '''‘age’''' of type '''int.'''&lt;br /&gt;
&lt;br /&gt;
So type '''''int age '''is equal to'' 20.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we will write an If statement as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''if '''within parentheses '''age&amp;lt;nowiki&amp;gt; &amp;lt; 21&amp;lt;/nowiki&amp;gt;''' curly brackets.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we are checking if '''age''' is less than '''21'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whatever is inside the brackets belongs to the if block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inside the brackets type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''System '''''dot '''''out '''''dot '''''println '''within brackets and double quotes''' The person is Minor.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, if '''age '''is less than '''21,''' then “'''The person is minor'''” will be displayed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us '''save''' and''' run '''this file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Highlight the output.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We get the output as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case, the person's age is''' 20''', which is less than '''21. '''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, we got the output as “'''The person is minor'''”.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 9'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Restore the slide)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''If…Else statement&amp;amp;nbsp;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Now, we will learn about '''if...else '''statement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If...Else statement is used to execute alternative statements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These are based on a single condition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 10'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Syntax for If…Else statement&amp;amp;nbsp;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if&amp;lt;nowiki&amp;gt; ( &amp;lt;&amp;lt;/nowiki&amp;gt;condition&amp;gt; ) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;/nowiki&amp;gt;statement_or_block&amp;gt; &lt;br /&gt;
&lt;br /&gt;
else &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;/nowiki&amp;gt;statement_or_block&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// end of if construct &lt;br /&gt;
&lt;br /&gt;
// program continues here&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us look at the syntax for writing the '''If…Else statement.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the condition is True, then the statement or block of code is executed..&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Else it executes another statement or another block of code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Example of If…Else statement'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''('''Please include the example in Eclipse. No need to show it on slide. Show how to run the program in Eclipse and then point to the output at the console.)'''&amp;amp;nbsp;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Type the code in Eclipse as per the explanation.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class Person&lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
int age&amp;lt;nowiki&amp;gt;=25; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
public static void main(String args&amp;lt;nowiki&amp;gt;[]) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
if(age&amp;gt;21) &lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
System.out.println(&amp;quot;The person is Major&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
System.out.println(&amp;quot;The person is Minor&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Highlight as you explain.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| We will now see how the '''If…else statement&amp;amp;nbsp;'''can be used in a program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we will write a program to identify whether the person is '''Minor or Major'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So inside the '''Main''' method type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''if '''''within brackets'' '''age''' ''greater than'' '''21''', &lt;br /&gt;
&lt;br /&gt;
then ''within curly brackets'' type '''System '''''dot''''' out '''''dot''''' println '''''within brackets '''''The person is Major.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then type &lt;br /&gt;
&lt;br /&gt;
'''else '''''within curly brackets'' type&lt;br /&gt;
&lt;br /&gt;
'''System''' ''dot '''''out''' ''dot'' '''println '''''within brackets'' '''The person is Minor.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, if the '''age''' ''is less than'' '''21''', then “'''The person is Minor'''” will be displayed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Else''' the “'''The person is Major” '''will be displayed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, '''save '''and''' run''' the program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Highlight the output and explain.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We get the output as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, the person's '''age''' is '''25,''' which is greater than '''21'''. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Therefore the program will display the output as “'''The person is Major'''”.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 11'''&lt;br /&gt;
&lt;br /&gt;
(Restore the slide)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''If…Else If statement&amp;amp;nbsp;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''If…Else If''' statement is used to execute various set of statements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These are based on the two given conditions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also add more conditions based on your requirement. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is also called as a''' branching '''or '''decision making statement.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 12'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Syntax for If…Else If statement&amp;amp;nbsp;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if&amp;lt;nowiki&amp;gt; ( &amp;lt;&amp;lt;/nowiki&amp;gt;condition 1&amp;gt; ) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;/nowiki&amp;gt;Statement_or_block 1&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
else if&amp;lt;nowiki&amp;gt; (&amp;lt;&amp;lt;/nowiki&amp;gt;condition 2&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;/nowiki&amp;gt;Statement of block 2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
else &lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;/nowiki&amp;gt;Statement_or_block 3&amp;gt;&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Let us look at the syntax for writing the '''If…Else If '''statement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This statement initially checks for '''condition 1.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If''' condition 1 '''is true, it executes the '''statement 1 '''or '''block code 1'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Else it again checks for '''condition 2.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If '''condition 2''' is true, it executes '''statement 2 '''or '''block code 2'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Else it executes '''statement 3''' or '''block code 3'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this way, we can extend the code by '''If…Else''' blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These blocks can have multiple conditions. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The corresponding code will get executed until it finds the true condition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If all the conditions are false, it will execute the final '''Else''' section.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Example of If…Else If statement&amp;amp;nbsp;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Minimize the slide and type the code according to the audio narration)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class Student &lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
public static void main(String args&amp;lt;nowiki&amp;gt;[]) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
int testScore&amp;lt;nowiki&amp;gt;=70; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if(testScore&amp;lt;nowiki&amp;gt;&amp;lt;35) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
System.out.println(&amp;quot;C grade &amp;quot;); &lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
else if((testScore&amp;gt;=35)&amp;amp;&amp;amp;(testScore&amp;lt;nowiki&amp;gt;&amp;lt;=60)) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
System.out.println(&amp;quot;B grade&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
else &lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
System.out.println(&amp;quot;A grade&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| We will see how the '''If…Else If statement&amp;amp;nbsp;'''can be used in a program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So switch to Eclipse.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I have already created a class named Student.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us write a program to identify grade of a student.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is done based on the score percentage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the''' Main''' method, type '''int''' ''space''''' testScore''' ''equal to''''' 70''' ''semicolon.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The input variable named ‘'''testScore'''’ is used to get the score percentage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then type''' if''' ''within brackets'' '''testScore''' ''is less than'' '''35, '''''within curly brackets '''''System '''dot''' out '''''dot println within brackets and double quotes''''' C grade '''''semicolon'''''.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the''' testScore''' is less than '''35''', then the program displays &amp;quot;'''C Grade'''&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next line type '''else '''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then next line type '''if'' '''within brackets''''' testScore '''''greater than or equal to'' '''35 '''and '''testScore '''''less than or equal to '''''60.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, the program will check for the second condition in the '''Else If''' section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the '''testScore''' is between '''35 '''and '''60''' then the program displays &amp;quot;'''B Grade'''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next line type '''else''''' within brackets'' type '''System''' ''dot '''''out''' ''dot'' '''println''' ''within brackets and double quotes'' '''A grade''''' semicolon''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, if both the conditions are '''False''', the program displays “'''A Grade'''&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, let us '''save''' and '''run''' this code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Highlight the output and explain&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We get the output as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this program, the student’s '''testScore''' is '''70''' .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So the output will be displayed as “'''A Grade'''”.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Change testScore&amp;lt;nowiki&amp;gt;=55;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Let us change the''' testScore''' to''' 55.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, '''save''' and '''run''' this program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Highlight the output as you explain.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We get the output as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case, the output will be displayed as “'''B Grade'''”.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| else if((testScore&amp;gt;=60)&amp;amp;&amp;amp;(testScore&amp;lt;nowiki&amp;gt;&amp;lt;=75)) &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{ &lt;br /&gt;
&lt;br /&gt;
System.out.println(&amp;quot;O grade&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
Highlight as you explain.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We can also increase the number of conditions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us add one more condition after the “'''B grade'''” output section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So type here, '''if''' ''within brackets''''' testScore''' ''greater than or equal to'' '''60 '''and''' testScore''' ''less than or equal to'' '''75.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then within curly brackets type '''System '''''dot '''''out''' ''dot '''''println''' ''within brackets and double quotes''''' O grade''' ''semicolon''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here if the '''testScore''' is between '''60''' and '''75''' then the program will display &amp;quot;'''O Grade'''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, change the '''testScore''' of the student to''' 70'''. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, '''save '''and''' run''' the file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| Highlight the output.&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| We get the output as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program will display the output as “'''O grade'''”.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is not “'''A grade'''” as it displayed before. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program will display “'''A grade'''” for the '''testScore''' greater than '''75.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 13'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Points to Remember'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| While coding conditional structures:&lt;br /&gt;
&lt;br /&gt;
* Always remember to add a semicolon while terminating a statement.&lt;br /&gt;
&lt;br /&gt;
* But don’t add semi-colons after the condition.&lt;br /&gt;
&lt;br /&gt;
* Add the block of code within curly braces.&lt;br /&gt;
* Curly braces are optional if the block contains a single statement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 14'''&lt;br /&gt;
&lt;br /&gt;
'''Summary'''&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| We have come to the end of this tutorial. &lt;br /&gt;
&lt;br /&gt;
In this tutorial, we:&lt;br /&gt;
&lt;br /&gt;
* Explained conditional statements&lt;br /&gt;
* Listed the types of conditional statements&lt;br /&gt;
* Used conditional statements: '''if, if...else and if...else if''' in Java programs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 15'''&lt;br /&gt;
&lt;br /&gt;
'''Assignment''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| Now take an assignment on writing java programs using conditional statements: '''if, if...else and if...else if '''statements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Write a java program to compare two values using '''if '''statement.&lt;br /&gt;
* Write a java program to check whether the given number is even or odd.&lt;br /&gt;
&lt;br /&gt;
Hint : use '''if...else '''statement.&lt;br /&gt;
&lt;br /&gt;
* Write a java program to find the biggest number among the three numbers.&lt;br /&gt;
&lt;br /&gt;
Hint : use '''if...else if '''statement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 16'''&lt;br /&gt;
&lt;br /&gt;
'''About the Spoken Tutorial Project'''&lt;br /&gt;
&lt;br /&gt;
* Watch the video available at[http://spoken-tutorial.org/What_is_a_Spoken_Tutorial  ][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial http][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial ://][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial spoken][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial -][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial tutorial][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial .][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial org][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial /][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial What][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial is][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial a][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial Spoken][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial Tutorial]&lt;br /&gt;
&lt;br /&gt;
* It summarizes the Spoken Tutorial project&lt;br /&gt;
&lt;br /&gt;
If you do not have good bandwidth, you can download and watch it&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| To know more about the '''Spoken Tutorial''' project, &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
watch the video available at the following link.&lt;br /&gt;
&lt;br /&gt;
It summarizes the Spoken Tutorial project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you do not have good bandwidth, you can download and watch it&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 17'''&lt;br /&gt;
&lt;br /&gt;
'''Spoken Tutorial Workshops'''&lt;br /&gt;
&lt;br /&gt;
The Spoken Tutorial Project Team&lt;br /&gt;
&lt;br /&gt;
* Conducts workshops using spoken tutorials&lt;br /&gt;
&lt;br /&gt;
* Gives certificates for those who pass an online test&lt;br /&gt;
&lt;br /&gt;
For more details, please write to [mailto:contact@spoken-tutorial.org contact][mailto:contact@spoken-tutorial.org @][mailto:contact@spoken-tutorial.org spoken][mailto:contact@spoken-tutorial.org -][mailto:contact@spoken-tutorial.org tutorial][mailto:contact@spoken-tutorial.org .][mailto:contact@spoken-tutorial.org org]&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| The Spoken Tutorial Project Team&lt;br /&gt;
&lt;br /&gt;
* Conducts workshops using '''spoken tutorials''' &lt;br /&gt;
* gives certificates for those who pass an online test. For more details, please write to '''contact AT spoken HYPHEN tutorial DOT org.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 18'''&lt;br /&gt;
&lt;br /&gt;
'''Acknowledgement'''&lt;br /&gt;
&lt;br /&gt;
* Spoken Tutorial Project is a part of the Talk to a Teacher project&lt;br /&gt;
&lt;br /&gt;
* It is supported by the National Mission on Education through ICT, MHRD, Government of India&lt;br /&gt;
&lt;br /&gt;
* More information on this Mission is available at&lt;br /&gt;
&lt;br /&gt;
[http://spoken-tutorial.org/NMEICT-Intro http][http://spoken-tutorial.org/NMEICT-Intro ://][http://spoken-tutorial.org/NMEICT-Intro spoken][http://spoken-tutorial.org/NMEICT-Intro -][http://spoken-tutorial.org/NMEICT-Intro tutorial][http://spoken-tutorial.org/NMEICT-Intro .][http://spoken-tutorial.org/NMEICT-Intro org][http://spoken-tutorial.org/NMEICT-Intro /][http://spoken-tutorial.org/NMEICT-Intro NMEICT][http://spoken-tutorial.org/NMEICT-Intro -][http://spoken-tutorial.org/NMEICT-Intro Intro]&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Spoken Tutorial '''Project is a part of the '''Talk to a Teacher''' project and is supported by the '''National Mission on Education through ICT, MHRD, Government of India. '''More information on this Mission is available at '''spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.176cm;&amp;quot;| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| '''Slide 19'''&lt;br /&gt;
&lt;br /&gt;
'''About the contributor'''&lt;br /&gt;
&lt;br /&gt;
* This tutorial has been contributed by TalentSprint&lt;br /&gt;
&lt;br /&gt;
* Website: www.talentsprint.com&lt;br /&gt;
&lt;br /&gt;
Thanks for joining&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| style=&amp;quot;border:0.035cm solid #000000;padding:0.097cm;&amp;quot;| This tutorial has been contributed by TalentSprint.&lt;br /&gt;
&lt;br /&gt;
Thanks for joining&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Arya</name></author>	</entry>

	</feed>