Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class End of Chapter 2: READ Section 2.15End of Chapter 2: READ Section.

Similar presentations


Presentation on theme: "March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class End of Chapter 2: READ Section 2.15End of Chapter 2: READ Section."— Presentation transcript:

1 March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class End of Chapter 2: READ Section 2.15End of Chapter 2: READ Section 2.15 Status on Lab 5?Status on Lab 5? IF Statement PitfallsIF Statement Pitfalls IF – ELSE – IFIF – ELSE – IF Nested IFNested IF “Boolean” Logical Operations“Boolean” Logical Operations Comparing String ObjectsComparing String Objects

2 March 2005 2/18R. Smith - University of St Thomas - Minnesota IF Statement Pitfalls ReviewReview –“Logical comparison” in parentheses –Skip the following statement if false Putting a semicolon after the conditionPutting a semicolon after the condition Indenting several statements w/o bracesIndenting several statements w/o braces –Curly braces = a single statement Indenting incorrectlyIndenting incorrectly

3 March 2005 3/18R. Smith - University of St Thomas - Minnesota More IF Features IF – ELSE – IFIF – ELSE – IF –So we can choose from alternatives –Example: Assigning grades Nested IFNested IF –Use curly braces to control the flow –Example: Loan money if 2 years on job and $25k salary “Boolean” Logical Operations“Boolean” Logical Operations –Boolean variables –! And && and || –Loan example revisited Order of Precedence p. 138Order of Precedence p. 138

4 March 2005 4/18R. Smith - University of St Thomas - Minnesota Comparing String Objects The boat analogyThe boat analogy –Illustrating the ‘wrongness’ The view in RAMThe view in RAM –Demonstrating the reality Comparison operatorsComparison operators –String st1, st2; –if (st1.equals(“st2”)) … real match –if (st1.compareTo(“st2”) == 0) … real match compareTo returns <0 if st1 < st2compareTo returns <0 if st1 < st2 compareTo returns >0 if st1 > st2compareTo returns >0 if st1 > st2 An ExperimentAn Experiment

5 March 2005 5/18R. Smith - University of St Thomas - Minnesota Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.


Download ppt "March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class End of Chapter 2: READ Section 2.15End of Chapter 2: READ Section."

Similar presentations


Ads by Google