 Let's talk about using braces in if statements. When you have exactly one statement after an if or else, as in this program, you can leave out the braces. If I run this program and enter a quantity of 10, I get no discount because quantity is less than 15. If I run the program again with a quantity of 20, I get the 10% discount because my quantity was greater than 15. Everything works fine. Now let's modify the program to let the user know that they got a 10% discount by adding this line. When we build the program, we get an error message. It tells us that this statement, the discount calculation, is not part of this if statement because the body of an if contains only one statement. By the way, the only reason we're seeing this warning message is that the IDE compiles programs with all warnings turned on. If your IDE doesn't do this, your program might have compiled successfully without any warnings at all. If you disregard the warning and run the program and enter 20 for the number of items, you get a message and you get the discount. But if you run the program and enter 10 for your quantity, you do get the discount without the message. Just as the warning said, even though this line is indented, as though we're inside the if statement, it really isn't. Because we left off braces, this is the only line that belongs to the if. This is what's really going on. Again, this calculation is totally independent of the if statement. This is not what we want. Instead, to make both statements part of the if, we have to enclose them in braces. Now when we build the program, there's no warning. When we execute the program with a quantity of 20, we get the message and the discount. When we run the program with a quantity of 10, we get the correct price without the discount and without the message. Another problem with leaving off braces happens when you have nested if statements with one else. What do you think will happen if you order 10 items in this program? The way it's written, your eyes tell you that you will get a 10% discount, because this else visually lines up with the first if. Because 10 is not greater than 20, your eye tells you that you'll get a 10% discount. Let's run the program and enter a quantity of 10. Surprise, we didn't get a discount. The reason is that an else is joined to the nearest if. What we really have is this situation here. The else belongs to the inner if, not to the outer one. Because the quantity of 10 is not greater than 20, all of this gets skipped and we get no discount at all. Because the question of ownership of the else is ambiguous, when we build the program, in fact the compiler will tell us this. Again, only because we have all warnings turned on. The only way to get rid of this warning message is to add braces. By putting braces where I want them, the compiler will be happy and also my meaning will be entirely clear to anyone else who is reading the program. Now when I build, there are no warnings, and when I execute the program, a quantity of 10 gives me no discount, which matches what my eyes tell me and what the braces tell me. Many books often leave off the braces when there's only one statement in the loop body. Other books tell you to be careful when writing if statements to put braces where they're needed. I say no. The real solution, which many style guidelines use, is to always use braces, even when there's only one statement. Because eventually you'll want to add another statement and now you need the braces. The ambiguous else problem is always solved by indenting properly and using braces everywhere. So why do we have this no braces with one statement rule anyway? Back in the 1980s when disk sizes were measured in megabytes or even kilobytes for personal computers and CPU speeds were on the microsecond scale, every byte counted and every extra byte in your source code slowed down compile speeds. In a large program, braces on 500 if statements would add a large burden. Minimizing source code was absolutely worth it. Now disk space is measured in gigabytes and CPUs run at nanosecond speed. So saving 1000 bytes and 100 nanoseconds at the expense of 10 minutes of your time debugging a program because you forgot the braces where you needed them? Absolutely not worth it. In summary, when you're writing if else statements as well as loops, use braces in all the places.