Download presentation
Presentation is loading. Please wait.
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) This complex condition is always false: – X 10 This complex condition is always true: – X >= 5 OR X <= 10
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 applicant’s 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?
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 a CIS student with GPA = 2.0 qualified? – GPA >= 3.2 AND Major = “Acct” OR Major = “CIS” Is this complex condition correct?
6
NOT Set 1: Young: Age < 30 Set 2: Rich: Income >= 100,000 YoungRich
7
Order of Evaluation 1. () 2. Not 3. AND 4. OR
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” Cname = “Chao” OR Cname = “Smith” Cname=“Chao” OR Rating=“A” OR City=“SF” Rating = “A” OR Rating = “B” AND City=“SF” (Rating = “A” OR Rating = “B”) AND City=“SF”
9
Entering Complex Condition Student table: SID, Sname, Major, GPA, Sex, FID Major=“CIS” OR GPA>3.0 AND Sex=“F” Major=“CIS” AND GPA>3.0 OR Sex=“F” (Major=“CIS” AND GPA>3.0 OR Major=“Acct”) AND Sex=“F” (Major=“CIS” AND GPA>3.0 OR Major=“Acct” AND GPA>2.5) AND Sex=“F”
10
Excel’s Advanced Filter Data/Filter/Advanced Filter – List range – Criteria range
11
Excel’s 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
13
Excel’s IF with Complex Condition Rules to calculate employee bonus are: – If JobCode = 1 AND Salary < 5000 Bonus = 10% * Salary – Otherwise: Bonus = 8% * Salary Rules to calculate employee bonus are: – If JobCode = 1 AND Salary < 5000 OR Sex = “F” Bonus = 10% * Salary – Otherwise: Bonus = 8% * Salary
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.