1 / 20

- Meeting 5 – Making Decision

- Meeting 5 – Making Decision. By: Felix Valentin, MBA. Today Topic:. Evaluate Boolean expressions to make comparisons Use the logical comparison operators Understand AND logic Understand OR logic. Evaluate Boolean expressions to make comparisons.

mead
Download Presentation

- Meeting 5 – Making Decision

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. - Meeting 5 –Making Decision By: Felix Valentin, MBA

  2. Today Topic: • Evaluate Boolean expressions to make comparisons • Use the logical comparison operators • Understand AND logic • Understand OR logic

  3. Evaluate Boolean expressions to make comparisons • The selection structure (sometimes called a decision structure) involved in programs is one of the basic structures of structured programming

  4. Evaluate Boolean expressions to make comparisons

  5. Flowchart and Pseudo code for Overtime Decision

  6. Flowchart and Pseudocodefor Dental Plan Decision

  7. Using Logical Comparison Operators • Usually, you can compare only values that are of the same type; that is, you can compare numeric values to other numeric values and character values to other characters • For any two values that are the same type, you can decide whether: • The two values are equal • The first value is greater than the second value • The first value is less than the second value

  8. Using Logical Comparison Operators • In any Boolean expression, the two values used can be either variables or constants • Such expressions are considered trivial because each always results in the same value: true for the first expression and false for the second • Each programming language supports its own set of logical comparison operators, or comparison symbols, that express these Boolean tests

  9. Using Logical Comparison Operators • In addition to the three basic comparisons you can make, most programming languages provide three others • For any two values that are the same type, you can decide whether: • The first is greater than or equal to the second • The first is less than or equal to the second • The two are not equal

  10. Using a Negative Comparison

  11. Using the Positive Equivalent of the Negative Comparison

  12. Using Logical Comparison Operators • Besides being awkward to use, the not equal to comparison is the one most likely to be different in the various programming languages you may use • Although NOT comparisons can be awkward to use, there are times when your meaning is clearest if you use one

  13. Understanding AND Logic • An AND situation requires a nested decision or a nested if; that is, a decision “inside of” another decision • When you nest decisions because the resulting action requires that two conditions be true, you must decide which of the two decisions to make first • Logically, either selection in an AND situation can come first • However, when there are two selections, you often can improve your program’s performance by making an appropriate choice as to which selection to make first

  14. Understanding AND Logic • Most programming languages allow you to ask two or more questions in a single comparison by using a logical AND operator • If you want to select employees who carry both medical and dental insurance, you can use nested ifs, or you can include both decisions in a single statement by writing empDentalIns = “Y” AND empMedicalIns = “Y”?

  15. Understanding AND Logic • Most programming languages allow you to ask two or more questions in a single comparison by using a logical AND operator • If you want to select employees who carry both medical and dental insurance, you can use nested ifs, or you can include both decisions in a single statement by writing empDentalIns = “Y” AND empMedicalIns = “Y”?

  16. Understanding OR Logic • Most programming languages allow you to ask two or more questions in a single comparison by using a logical OR operator • When you use the logical OR operator, only one of the listed conditions must be met for the resulting action to take place

  17. Understanding OR Logic • Most programming languages allow you to ask two or more questions in a single comparison by using a logical OR operator • When you use the logical OR operator, only one of the listed conditions must be met for the resulting action to take place

  18. Logic Table

  19. Practice • Create a pseucedo code and flowchart for condition below:

  20. Case Project • Create a pseucedo code and flowchart for Shio and zodiac application • Example : • User Input Birth Date : 30 April 1988 • Shio : Dragon • Zodiac : Taurus

More Related