Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Conditionals and Boolean Logic2-1-2010Opening Discussion●Do you have any questions about the quiz?●How is the reading going? Please suggest changes or let me know when you find errors/typos.●Minute Essays–Purpose of IcPs. Seeing what you really understand.–Feeling limited in what you can do?Our Problem●Last time we fixed our division by zero using an if statement.●We might also want the person to do something when it gets where it is going.●We could also rewrite walkToward() and pace() so that they use conditionals instead of math.Full Syntax of if●We will normally write an if statement with the following syntax.–if(condition) {●statements–} [ else {●statements–} ]●The first statements only execute if the condition is true.●Else is optional, executes if condition is false.Comparison Operators●If you want to compare two numbers use the following.–== for equality. Note there are two of them.–!= for inequality.–>, <, >=, <= for what they look like.●With objects you generally want to call the equals method.–if(v1.equals(v2)) ...Boolean Logic●We only want the person to enter the house if both dx and dy are zero. To do this we use Boolean logic.●Logic operators–|| is inclusive or.–&& is and.–! is not.●Let's look at truth tables for these.●Use parentheses to group things.Minute Essay●Do you have any questions about conditionals or Boolean logic?●The next round of interclass problems will be this coming
View Full Document