Presentation is loading. Please wait.

Presentation is loading. Please wait.

Complex Conditions. Logical Operators: AND, OR, NOT AND Cond1Cond2Cond1 AND Cond2T TF FTF OR Cond1Cond2Cond1 OR Cond2T TF FTF NOT CondNOT Cond T F.

Similar presentations


Presentation on theme: "Complex Conditions. Logical Operators: AND, OR, NOT AND Cond1Cond2Cond1 AND Cond2T TF FTF OR Cond1Cond2Cond1 OR Cond2T TF FTF NOT CondNOT Cond T F."— Presentation transcript:

1 Complex Conditions

2 Logical Operators: AND, OR, NOT AND Cond1Cond2Cond1 AND Cond2T TF FTF OR Cond1Cond2Cond1 OR Cond2T TF FTF NOT CondNOT Cond T F

3 Examples Write a complex condition for: 12 <= Age <= 65 Use a complex condition to describe age not between 12 and 65. X <= 15 is equivalent to: X<15 AND X =15? (T/F)

4 More Complex Conditions University admission rules: Applicants will be admitted if meet one of the following rules: – 1. Income >= 100,000 – 2. GPA > 2.5 AND SAT > 900 An applicants Income is 150,000, GPA is 2.9 and SAT is 800. Admitted? – Income >= 100,000 OR GPA > 2.5 AND SAT >900 How to evaluate this complex condition? – AND has higher priority

5 Scholarship: Business students with GPA at least 3.2 and major in Accounting or CIS qualified to apply: – 1. GPA >= 3.2 – 2. Major in Accounting OR CIS Is this complex condition correct? – GPA >= 3.2 AND Major = Acct OR Major = CIS – Try: A CIS student with GPA=2.0 Need parenthesis, ( ) – GPA >= 3.2 AND (Major = Acct OR Major = CIS )

6 Order of Evaluation 1. () 2. And 3. Or

7 Entering Complex Condition StudentTable: SID, Sname, Major, Sex, FID, GPA Major = CIS and Sex=F Major = CIS OR Sex=F Major=CIS AND GPA>2.5 OR Major=Acct AND GPA>2.7 GPA>2.5 OR Major=CIS AND Sex=F (GPA>2.5 OR Major=CIS) AND Sex=F (Major=CIS AND GPA>3.0 OR Major=Acct) AND Sex=F

8 Entering Complex Condition Customer Table: CID, Cname, City, Rating Rating=A AND City=SF Rating=A OR City=SF Rating = A OR Rating = B AND City=SF

9 Employee Table: EmpID, EMpName, Sex, Race, BirthDate, HireDate, Salary, Dept (Sex = Female OR Dept=A) AND Race = Hispanic (Sex = Male OR Sex=male OR Salary>50000) AND Race = Asian (Sex = Male OR Sex=male AND Salary>50000) AND Race = Asian Sex = Female Or Sex=male AND Race = Hispanic OR Dept = A

10 Excels Advanced Filter Data/Filter/Advanced Filter – List range – Criteria range

11 Excels AND Function/OR Function =AND (cond1, cond2, …, cond n) – Up to 30 conditions – True if all conditions are true – False if any condition is false =OR (cond1, cond2, …, cond n) – True if any condition is true – False if all conditions are false

12

13 Excels IF with Complex Condition Event admission fee: – If 12<=Age<=65 Fee=20 – Otherwise, free Rules to calculate employee bonus are: – If JobCode = 1 AND Salary < 5000 Bonus = 10% * Salary – Otherwise: Bonus = 8% * Salary


Download ppt "Complex Conditions. Logical Operators: AND, OR, NOT AND Cond1Cond2Cond1 AND Cond2T TF FTF OR Cond1Cond2Cond1 OR Cond2T TF FTF NOT CondNOT Cond T F."

Similar presentations


Ads by Google