Lesson+09-+The+If+Statement

__**//If// Statement**__

The if statement is one of Java's most useful "decision making" tools.
 * Ex:**

//**//Get a grade from the keyboard **// Scanner kbReader = new Scanner(System.in); System.out.print(“What is your grade? ”); int myGrade = kbReader.nextInt; **//Make a decision based on the value of the grade you entered ** if (myGrade >= 70) {

//**//Execute code here if the test above is true **// System.out.println(“Congratulations, you passed.”); }

else {


 * //Execute code here if the test above is false **

System.out.println(“Better luck next time.”); } . . . So, the **__if__** is going to give java two paths (or options) to follow. So whatever you input as the "user input" in the code " System.out.print(“What is your grade? ”); "", will be compared to the code "" if (myGrade >= 70) "". So looking at the example code up above, if your grade is equal to 70 or above, the output will be **Congratulations, you passed.** The other path (option) for java is if the "user input" is any number below 70, the output will be **Better luck next time**.

We don't really need the else part... "System.out.println(“Congratulations, you passed.”); ﻿﻿} __** else **__ {  //Execute code here if the test above is false  System.out.println(“Better luck next time.”);  }"