Today we learned the following:
-If/else statements review
if statements use the following format:
if (boolean_expression) {
//run something
} else {
//if the code in the if block isn't ran, run this
}
boolean_expression should equal true in order for the code in the block to be ran.
Else ifs are also used, but you must have an if statement first. If the first one isn't satisfied, it'll run the following until it reaches the end or the else statement. Note that once an if or if else condition is met none of the other blocks will run.
We then completed several problems that involved the use of if statements and a kahoot.
Nested if-else:
We can put two if statements inside one another. That way, the code inside the second will only be run if both are true, and code inside the first will be run if only that one is true.
https://replit.com/@offexe/12-01hw#Main.java Solution