Seating “chart” Front - Screen 3 2 4 4 rows 1 5 6 Back DOOR.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Repetition Statements Perform the same task repeatedly Allow the computer to do the tedious, boring things.
Iteration While / until/ for loop. Iteration: while/ Do-while loops Iteration continues until condition is false: 3 important points to remember: 1.Initalise.
While loops.
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
How SAS implements structured programming constructs
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
Fundamental Programming Structures in Java: Control Flow, Arrays and Vectors.
Basic Control Structures Control order of execution of statements sequential selection iteration - Repeat some action while a certain condition is true.
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
Repetition Statements repeat block of code until a condition is satisfied also called loops Java supports 3 kinds of loops: while statement – repeats a.
An Introduction to Programming with C++ Fifth Edition
Week 11 Recap CSE 115 Spring Want to write a programming language? You’ll need three things: You’ll need three things: –Sequencing –Selection Polymorphism.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
Control Structures II. Why is Repetition Needed? There are many situations in which the same statements need to be executed several times. Example: Formulas.
Chapter 4: Control Structures II
Do … while ( continue_cond ) Syntax: do { stuff you want to happen in the loop } while (continue_condition);
LOOPING What are the 3 structures of writing code? sequential decision repetition Def. Looping is the repetition of statements in a program. There various.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
Repetition Statements.  Often it is necessary to repeat statements many times  Java has two ways of doing this  while statements  for statements.
Lecture 4 Looping. Building on the foundation Now that we know a little about  cout  cin  math operators  boolean operators  making decisions using.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Repetition and Iteration ANSI-C. Repetition We need a control instruction to allows us to execute an statement or a set of statements as many times as.
February ,  2/16: Exam 1 Makeup Papers Available  2/20: Exam 2 Review Sheet Available in Lecture  2/27: Lab 2 due by 11:59:59pm  3/2:
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
CONTROL STATEMENTS LOOPS. WHY IS REPETITION NEEDED?  There are many situations in which the same statements need to be executed several times.  Example:
Repetition Control Structure. Introduction Many applications require certain operations to be carried out more than once. Such situations require repetition.
Looping ROBERT REVAES. Logical Operators  && AND  Both have to be true for it to evaluate to be true.  || OR  One or the other has to be true for.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Expressions Methods if else Statements Loops Potpourri.
CMSC 150 LOOPS CS 150: Fri 20 Jan Representing DNA AGTCCAGTGTCAA.
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
Computer Programming 12 Lesson 6 – Loop structure By: Dan Lunney.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
LESSON 5 Loop Control Structure. Loop Control Structure  Operation made over and over again.  Iterate statement.
Follow up from lab See Magic8Ball.java Issues that you ran into.
Loops A loop is: Java provides three forms for explicit loops:
Chapter 4 Repetition Statements (loops)
REPETITION CONTROL STRUCTURE
Introduction To Repetition The for loop
Loops in Java.
Chapter 5: Control Structures II
CiS 260: App Dev I Chapter 4: Control Structures II.
Web Programming– UFCFB Lecture 16
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
all loops initialization – set up the loop
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Looping and Repetition
Iteration with While You can say that again.
LRobot Game.
Chapter 9 Control Structures.
In this class, we will cover:
Lecture Notes – Week 3 Lecture-2
Control Statements Loops.
Chapter 8: More on the Repetition Structure
Loop Strategies Repetition Playbook.
Flow of Control.
In this class, we will cover:
Programming Right from the Start with Visual Basic .NET 1/e
Repetition Statements (Loops) - 2
Control Statements Loops.
PROGRAM FLOWCHART Iteration Statements.
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Code examples MakingCircles.java Circle.java Loopy.java
Looping and Repetition
Presentation transcript:

Seating “chart” Front - Screen 3 2 4 4 rows 1 5 6 Back DOOR

Follow up from lab See Magic8Ball.java “solution” Issues that you ran into.

Code examples Loopy.java Loops Code examples Loopy.java

Why loops? Where have we wanted to use a loop? What kinds of problems lend themselves to iteration? What do Java loop structures look like?

4 parts to a loop Initialization – getting it ready Decision – Do I continue the loop – boolean expression Body – What do I want to accomplish in a loop Update – How do I approach the false condition to exit the loop?

The while loop Flowchart statement(s) true boolean expression? false while loops are indeterminant loops, we execute until a condition is met and not for any pre – determined number of times. while (result < 10) { ….. do something } Another name is precondition loop – You evaluate the condition before executing the body.

The while loop Flowchart statement(s) true boolean expression? false Another name is precondition loop – You evaluate the condition before executing the body.

The while loop Flowchart statement(s) true boolean expression? false Another name is precondition loop – You evaluate the condition before executing the body.

The while loop Flowchart statement(s) true boolean expression? false Another name is precondition loop – You evaluate the condition before executing the body.

The do-while Loop Flowchart statement(s) true boolean expression? false do { … statements } while (condition); Another name is post condition loop – You evaluate the condition after executing the body.

The do-while Loop Flowchart statement(s) true boolean expression? false Another name is post condition loop – You evaluate the condition after executing the body.

The do-while Loop Flowchart statement(s) true boolean expression? false Another name is post condition loop – You evaluate the condition after executing the body.

The do-while Loop Flowchart statement(s) true boolean expression? false Another name is post condition loop – You evaluate the condition after executing the body.

The for Loop Flowchart statement(s) true boolean expression? false update for (int ii = 0; ii < 10; ii++) { … statements } In a for loop, the initialization, boolean expression and update are combined in one structure. Another name is counted loop – You typically will execute a for loop based on some counter. A for loop is also a precondition loop.

Code example Loopy.java Some terms loop control variable precondition loop post condition loop counted loop