 Here's the flowchart for what the book calls a multi-way if-else. Depending on the percent of your maximum heart rate, this tells what training zone you're in. Let's try it with 73% of your maximum heart rate. Is 73% less than 60%? No, it isn't. That leads us to another question. Is 73% less than or equal to 70? No, it isn't. Which leads us to this question. Is 73% less than or equal to 80%? Yes, it is. So our training zone is moderate and we've finished. The flowchart translates into this code. Let's trace through it again. Since 73 is not less than or equal to 60, we follow the else, and then ask if 73 is less than or equal to 70. It isn't, so we follow the corresponding else. We ask if 73 is less than or equal to 80. It is, so we print moderate and don't do the else. You may be wondering why we didn't write this code with compound conditions like this. Let's follow through again with 73% of the maximum heart rate. Is 73 less than or equal to 60? No, it isn't. Since it isn't less than or equal to 60, it must be greater than 60. When we get here, we don't need to ask that question again. We already know the answer. Now, is 73 less than or equal to 70? No, it isn't. That means when we get here, we know that it must be greater than 70, because it wasn't less than or equal, and we don't have to ask that question either. Similar logic applies for the first condition in the last if, the percent greater than 80.0. When you nest if-else sequences into a multi-way if-else, you can avoid testing unnecessary conditions. There's nothing wrong with indenting and putting braces around this chain of if-else statements, but if we had a couple of more heart rate levels, we'd be marching off the right-hand side of the screen. Remember I said this in a preceding video? Braces in all the places? Now it's time to amend that. Braces in almost all the places. The block that's outlined in red is really one gigantic statement. So I'm going to set aside the rule of always using braces and join the else to the preceding if. The same logic applies here. The red outlined statement is one statement so the else and if can be joined together. And the same can be done with the last statement, and I end up with this. This is far easier to read as all of the conditions line up nicely. With this if-else shortcut, I can now add more conditions without worrying about indenting too deeply. The only time you can use this shortcut is when an if immediately follows an else. Adding these statements before the else forces us to use braces all the way. By the way, if you ran this code with a 73 for the input as the percent, what output would you see? Try and figure it out, and then type this code into a program, run it, and see what actually happens. Most of the time when you have an if-else chain, your conditions will be testing the same variable. In this chain, in this multi-way if-else, all of the conditions are testing the variable percent, but there's no law that this has to be the case. As long as the if immediately follows an else, you can have a multi-way if-else that checks different variables, as you see in this sequence, that determines the price of a movie ticket, depending on the customer's age as the first condition, the day of week as the second condition, and the hour of the day as the third condition. As a test of your understanding, you might want to write a program with code like this. Try various combinations of age, day, and hour, and see if you can tell what the output will be before you run the program.