- meeting 5 – making decision by: felix valentin, mba

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

Upload: bernadette-mae-barker

Post on 23-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

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

- Meeting 5 –Making Decision

By: Felix Valentin, MBA

Page 2: - 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

Page 3: - Meeting 5 – Making Decision By: Felix Valentin, MBA

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

Page 4: - Meeting 5 – Making Decision By: Felix Valentin, MBA

Evaluate Boolean expressions to make comparisons

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

Flowchart and Pseudo code for Overtime Decision

Page 6: - Meeting 5 – Making Decision By: Felix Valentin, MBA

Flowchart and Pseudo codefor Dental Plan Decision

Page 7: - Meeting 5 – Making Decision By: Felix Valentin, MBA

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

Page 8: - Meeting 5 – Making Decision By: Felix Valentin, MBA

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

Page 9: - Meeting 5 – Making Decision By: Felix Valentin, MBA

• 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

Using Logical Comparison Operators

Page 10: - Meeting 5 – Making Decision By: Felix Valentin, MBA

Using a Negative Comparison

Page 11: - Meeting 5 – Making Decision By: Felix Valentin, MBA

Using the Positive Equivalent of the Negative Comparison

Page 12: - Meeting 5 – Making Decision By: Felix Valentin, MBA

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

Page 13: - Meeting 5 – Making Decision By: Felix Valentin, MBA

• 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

Understanding AND Logic

Page 14: - Meeting 5 – Making Decision By: Felix Valentin, MBA

• 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”?

Understanding AND Logic

Page 15: - Meeting 5 – Making Decision By: Felix Valentin, MBA

• 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”?

Understanding AND Logic

Page 16: - Meeting 5 – Making Decision By: Felix Valentin, MBA

• 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

Understanding OR Logic

Page 17: - Meeting 5 – Making Decision By: Felix Valentin, MBA

• 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

Understanding OR Logic

Page 18: - Meeting 5 – Making Decision By: Felix Valentin, MBA

Logic Table

AND True FalseTrue TRUE FALSEFalse FALSE FALSE

OR True FalseTrue TRUE FALSEFalse FALSE FALSE

Page 19: - Meeting 5 – Making Decision By: Felix Valentin, MBA

Practice

• Create a pseucedo code and flowchart for condition below:

Price (USD) Status Result

< 200 A / B Open

< 200 C Close

200 – 1.000 A Close

200 – 1.000 B Open

200 – 1.000 C Close

> 1.000 A / C Open

> 1.000 B Close

Page 20: - Meeting 5 – Making Decision By: Felix Valentin, MBA

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