27
1 CSE 2337 Chapter 4 Logic

1 CSE 2337 Chapter 4 Logic. 2 Objectives Boolean Values Logical Operators Conditional Logic Nested Functions

Embed Size (px)

Citation preview

1

CSE 2337Chapter 4

Logic

2

Objectives

• Boolean Values• Boolean Values• Logical Operators• Conditional Logic• Nested Functions

3

Boolean Logic

• Boolean Logic Values– True– False

4

Background Scenario

• Dun & Bradstreet® (D&B)– Widely used financial reporting services– Provides financial information about

corporations and institutions and extensive analyses on each company’s creditworthiness and payment history (PAYDEX® index)

• Create formulas by applying several credit approval indicator rules to each customer’s data

5

6

Rule #1

Accept a customer who has a past due balance that is

less than 10% of this year’stotal sales

Is past due balance less than10% of this year’s total sales?

In Other Words:

7

Relational Operators

• Compare to values and determine if True or False

8

Rule #1 Applied

9

Rule #2

Accept a customer who has eithera composite credit appraisal value

of 1 or a PAYDEX score over 90

10

Rule #2

Accept a customer who has eithera composite credit appraisal value

of 1 or a PAYDEX score over 90

2 conditions that bothhave a truth value

Reduce to one Truth value

11

Boolean Logic Functions

AND Used to determine if all arguments are TRUE

OR Used to determine if either argument is TRUE

NOT Evaluates only one logical argument to determine if it is FALSE

12

AND

13

OR

14

NOT

15

Logic Functions in Excel

• OR (logical1,logical2,….)• AND (logical1,logical2,…)• NOT (logical1)

16

Applying Rule #2

17

Rule #3

• Accept a customer who has all of the following:– Net worth of at least $500,000– Composite credit appraisal value of

2 or lower– PAYDEX score over 70– Stress risk class of 1

18

Applying Rule #3

19

Cell M3

20

IF Conditional

• IF function– Boolean logical function that returns different

values (TRUE or FALSE) depending on how the specified condition evaluates

– =IF(logical_test,value_if_true,value_if_false)

• Nested function (permitted by IF function)– Contains additional formulas and/or functions

as one or more of its arguments

• Provides flexibility of choosing between two different sets of criteria, and up to seven different levels of logical tests

21

EXAMPLE

22

If to perform conditional calcuations

23

Conditional Calc with IF

24

Explanation

25

Nested IFs

Nesting IF functions, one inside the other, allows you to ask a question, then another question depending on the outcome of the first question, and so on

26

Nested IFs

27

Nested IF