Monday, July 12, 2010

Day 15

Logic

One concept in mathematics students often fail to see the relevance of is truth tables. "Who could possiblly need to know when conditional statements are true? What's with all these p's and q's anyway?" Today, I got a "real-world" example to use in class.

We were working on a program that lets you set up promotions. For example, I want to reward a customer who spends over $50 on meat with a 15% discount. The register system has to know when to trigger this reward.

It is possible to specify multiple conditions. The choice the user has to make as he/she adds a condition is whether to choose "and" or "or". Now "or" can be a little bit of a stickler. In the English language "or" usually means one or the other, but not both. In mathematics, however, we are much more inclusive.

Let's say that you have two conditions. $20 in meat or dairy. One interpretation of this is a total of $20 in meat and dairy, say $15 in meat and $5 in dairy. The other interpretation is a total of $20 in meat or a total of $20 in dairy. There was no way to test it without setting it up at a store and scanning items to determine which way it works. Or of course, you could go ask the developers, but where's the fun in that.

No comments:

Post a Comment