Lec 04 Selection

Lec 04 Selection - FIT1002 Computer Programming 2010...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
FIT1002 Computer Programming 2010 Module 4 Selection www.monash.edu.au FIT1002 Computer Programming Semester 1, 2010 Module 4 – Selection COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University pursuant to Part VB of the Copyright Act 1968 (the Act). The material in this communication may be subject to copyright under the Act. Any further reproduction or communication of this material by you may be the subject of copyright protection under the Act. Do not remove this notice. The authors acknowledge that material in these modules has been adapted from slides produced by Lewis, DePasquale and Chase for Java Foundations: Introduction to Programming and Data Structures , Addison-Wesley, 2007 2 Assumed Knowledge Before the beginning of this lecture, students should be familiar with: – the concept of objects and classes – how to use the Scanner class for input – how to write output to screen – how to use the String and Math classes Before the beginning of this lecture, students should have read over: – Lewis et. al Chapter 4: Sections 4.1 – 4.3 – the entire set of lecture notes up to this point 3 Objectives By the end of this lecture students should Understand boolean operators and expressions Understand the need for control structures Understand selection statements Understand cascaded and nested selection Be able to write simple code with conditional execution
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
FIT1002 Computer Programming 2010 Module 4 Selection 4 Control structures The flow of control in a running program refers to the order in which the statements are executed The statements within a program are usually executed in a linear fashion unless specified otherwise We use three control structures: Sequence Selection (branch) Repetition (Loop) 5 Selection An statement that decides which of two possible sequences is executed The decision is based on a single true/false condition Example: – What to wear algorithm 6 if (its hot) { slip on a hat slop on some sunscreen slap on a shirt } else { slip on pants slip on long sleeve shirt } Selection Example – what to wear Algorithm
Background image of page 2
FIT1002 Computer Programming 2010 Module 4 Selection 7 if (its hot) { slip on a hat slop on some sunscreen slap on a shirt } else { slip on pants slip on long sleeve shirt } Selection Example – What to wear Algorithm Should be a true or false condition. (temperature > 30) 8 if (temperature >30) { slip on a hat slop on some sunscreen slap on a shirt } else { slip on pants slip on long sleeve shirt } Selection Example - Car Repair Algorithm Should be a true or false condition. Sequence if the condition is true. 9 if (temperature >30) { slip on a hat slop on some sunscreen slap on a shirt } else { slip on pants slip on long sleeve shirt } Selection Example - Car Repair Algorithm Sequence if the condition is false.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

Lec 04 Selection - FIT1002 Computer Programming 2010...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online