110 likes | 212 Views
Introduction to Logic and Conditional Block. Dr. José M. Reyes Álamo. Pending Items. Post the following Labs into your OpenLab portfolio ASAP: Android Zoo App PaintPot
E N D
Introduction to Logic and Conditional Block Dr. José M. Reyes Álamo
Pending Items • Post the following Labs into your OpenLab portfolio ASAP: • Android Zoo App • PaintPot • I started grading and most of you don’t have them. You must post them by midnight to get credit before I do my final round of grading. • Post you final project idea into your OpenLab portfolio with the following information: • App you are planning to develop • Your team member • Even though you will work in groups, portfolios will be graded individually.
Outline • Boolean expressions • Relational operators • If and Ifelse statement
AND operators (&) = All statements must be TRUE for the operation to be TRUE. AND operator STATEMENT 1 AND STATEMENT 2 TRUE TRUE & TRUE • Example: • Check if the following operation is TRUE or FALSE • X>10 & Y<=-4 • If X = 11 and Y = 1 • 11>10 & 1<=- 4 • If X=20 and Y -10 • 20>10 & -10<=-4 TRUE AND FALSE FALSE TRUE AND TRUE TRUE
OR operator • OR operators (|) = At least one statement must be TRUE for the operation to be TRUE. STATEMENT 1 OR STATEMENT 2 TRUE FALSE || TRUE FALSE FALSE || FALSE • Example: • Check if the following operation is TRUE or FALSE • X>10 || Y<=-4 • If X = 11 and Y = 1 • 11>10 || 1<=- 4 • If X=2 and Y =2 • 2 >10 || 2<=- 4 TRUE OR FALSE TRUE FALSE OR FALSE FALSE
NOT operator • NOT operator (!, ~) = Inverts the Boolean value of a variable or expression. NOT STATEMENT 1 ! TRUE = FALSE ! FALSE = TRUE !(11>10)= FALSE
If and ifelse statement Test statement If test statement is TRUE, then do the following.. If test statement is TRUE, then do the following… If test statement is FALSE, then do the following… If test statement is FALSE, skip the if statement
Algorithm – Pseudo Code // Use if statement to check the default size. defaultSize = 5; smallSize = 3; bigSize = 8; If defaultSize<8 &&defaultSize>3 Display in LabelResult = The dot size is set to default; end
ASSIGNMENTS • Idea for final project due TODAY • IN CLASS LAB: • LAB9 QuizMe • READING ASSIGNMENTS: • AppInventor CH20 (Repeating Blocks) • AppInventor CH22 (Working with Databases) • READING ASSIGNMENT EVALUATION: • Complete the reading assignments (2 CHAPTERS) and answer the RA10_AppInventorCh20andCh22 on Blackboard. • First draft for final project due NEXT WEEK.