Often in a program, we need to compare variables or objects. For instance, to determine whether someone can shop online, we want to know if the person’s age is at least 18. Or, if we are adding students to the honor roll, we want to add only those students with averages of 90 or better. Similarly, if we are sending warnings to students, we want to send those warnings only to students whose averages are below 60.
Java provides equality, relational, and logical operators to evaluate and test whether an expression is true or false. It also provides selection statements to transfer control to a different part of the program depending on the result of that test:
What are the issues that may arise while using the IF statement?
In what circumstances would IF … ELSE be a preferred statement over SWITCH and vice versa? Please use real-world examples to support your arguments.
Use specific, real-world examples to describe the uses of the logical AND operator (&&), the logical OR operator (||), the logical NOT operator (!) and the combination of those operators in making decisions.