Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
If statements can use comparisons to control the flow of your code, a comparison is only useful when
it's inside of an IF statement.
So in this lesson, you're going to use statements to control how your code runs.
As usual, we're going to start by creating a new class inside the Section three folder, create a new
file named FLC Java and make sure the class has a main method.
The if statement runs, it's code only if a condition is true.
This is a comparison, but when a comparison is inside of a statement, we call it a condition.
There are two parts to in a statement, the condition which can be true or false and the code inside
which only runs if the condition is true.
So inside of Java, we're going to make an invariable that stores a student's grade into grade is equal
to 65.
Then we're going to make an if statement if and inside the brackets, we're going to read a condition
that checks if a grade is greater than 50.
And inside the if statement, we're going to print.
Great job.
You passed.
This code will only run if the condition is true.
So we're going to run our code.
And it ran the code inside the statement.
That's because the grade 65 is bigger than 50, which makes the condition true.
So the code inside the if statement runs.
Now we're going to change the students grade to 45.
Rewrite our code.
And nothing happens.
The grid is not bigger than 50, which makes the condition false.
So Java skips the code.
When the if condition is false, Jova runs the false statement.
And if a statement looks like this, there is an if statement with a condition and an el statements.
And when the condition is true, Juvy runs the estimates.
And when the condition is false, Java skips the statement and runs the code inside else.
So back in our code, if a student scores under 50, we want the app to say study hard next time, so
we're going to add an else block.
And inside will print study hard next time.
Rerun your code.
And this time the code inside the statement runs, never going to change the grade back to 65.
We run your code once more.
And this time at Prince, great job you passed.
We need to be careful about putting in the right condition, let's assume that if 50 percent warrants
a pass, but our condition checks if the grid is greater than 50.
I'm going to change the grade to 50 and see what happens, rewriting my code.
And that's not good, the condition is false.
So the student fails.
We need to fix our conditions is that the student policies, if they're great, as greater than or equal
to 50.
Let's rerun the code.
And right on the student pass with a D minus.
In this case, the grid is equal to 50, so the condition is true and this runs the code inside the
statements.
In this lesson, you learn to use if statements to control how your code runs.
When the condition is true, Jova runs the if statements.
When the condition is false, Java skips the statement and runs the code inside ls.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.