Repeating Structures For Loops. Repeating Structures Tasks we need to complete are often very repetitive. Once a task has been mastered, repeating it.

Slides:



Advertisements
Similar presentations
Repetition Statements Perform the same task repeatedly Allow the computer to do the tedious, boring things.
Advertisements

Chapter 4 Ch 1 – Introduction to Computers and Java Flow of Control Loops 1.
For(int i = 1; i
Looping Structures: Do Loops
Week 5: Loops 1.  Repetition is the ability to do something over and over again  With repetition in the mix, we can solve practically any problem that.
June 10, 2015ICS102: while & do-while1 while and do-while Statements.
1 10/11/06CS150 Introduction to Computer Science 1 do/while and Nested Loops.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
University of British Columbia CPSC 111, Intro to Computation 2009W2: Jan-Apr 2010 Tamara Munzner 1 Loops I Lecture 17, Fri Feb
Repetition Structures: For Loop Constants CSC 1401: Introduction to Programming with Java Week 5 Wanda M. Kunkle.
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Loops Lecture 12, Tue Feb
Repetition Structures: Do-while Loop Random Number Generation CSC 1401: Introduction to Programming with Java Week 6 Wanda M. Kunkle.
Copyright © Texas Education Agency, Computer Programming For Loops.
CS 106 Introduction to Computer Science I 09 / 28 / 2007 Instructor: Michael Eckmann.
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
Adding Automated Functionality to Office Applications.
1 for Loops Computer Science is a science of abstraction - creating the right model for a problem and devising the appropriate mechanizable techniques.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Ref :
Week 5 - Wednesday.  What did we talk about last time?  Exam 1!  And before that?  Review!  And before that?  if and switch statements.
CPS120 Introduction to Computer Science Iteration (Looping)
Repetition & Loops. One of the BIG advantages of a computer: ­It can perform tasks over and over again, without getting bored or making mistakes (assuming.
Repetition Statements.  Often it is necessary to repeat statements many times  Java has two ways of doing this  while statements  for statements.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 7 Clicker Questions September 22, 2009.
Flow Control in Java. Controlling which instruction to execute next Sequential  Similar to walking, one step after another Branching  Similar to a fork.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
1 CSCI N201 Programming Concepts and Database 9 – Loops Lingma Acheson Department of Computer and Information Science, IUPUI.
Repetition. Control of Flow SEQUENCE SELECTION (if..else, switch…case) REPETITION.
CMP-MX21: Lecture 5 Repetitions Steve Hordley. Overview 1. Repetition using the do-while construct 2. Repetition using the while construct 3. Repetition.
Today’s Announcements Assignment 8 is due Project 2 is due 7/27/04 We will be skipping chapter 22 Test 3 (chapters 18-21) will be on 7/29/04 Tip of the.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CPS120 Introduction to Computer Science Iteration (Looping)
Compilers and Interpreters. HARDWARE Machine LanguageAssembly Language High Level Language C++ Visual Basic JAVA Humans.
Week 6 - Monday.  What did we talk about last time?  while loop examples  Lab 5.
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.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING While Loop.
Shapes and Crystal Flowers KS2: Use repetition in programs.
Loops Tonga Institute of Higher Education. Introduction Programs need to be able to execute tasks repeatedly. Use loops to repeat actions  For Loop 
PHY 107 – Programming For Science. Today’s Goal  How to use while & do / while loops in code  Know & explain when use of either loop preferable  Understand.
Repetition In today’s lesson we will look at: why you would want to repeat things in a program different ways of repeating things creating loops in Just.
Identify the Appropriate Method for Handling Repetition
Lecture 6 Repetition Richard Gesick.
Scratch: iteration / repetition / loops
Topic 5 for Loops -Arthur Schopenhauer
Loops in C C has three loop statements: the while, the for, and the do…while. The first two are pretest loops, and the the third is a post-test loop. We.
Introduction Java Chapter 3.
Lecture 4A Repetition Richard Gesick.
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Looping and Repetition
Loops October 10, 2017.
Alice in Action with Java
LRobot Game.
Unit 3 - The while Loop - Extending the Vic class - Examples
© A+ Computer Science - What is a LOOP? © A+ Computer Science -
Early - I can develop a sequence of instructions and run them using programmable devices or equivalent Designs a simple sequence of instructions/algorithm.
Building Java Programs
Introduction to Repetition Structures
The for loop suggested reading:
Repetition Statements (Loops) - 2
Stage 6 Maze: Loops.
The structure of programming
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.
Thinking procedurally
The while Looping Structure
Is there an alternative to copy-paste for repeating code?
Looping Structures.
Looping and Repetition
Presentation transcript:

Repeating Structures For Loops

Repeating Structures Tasks we need to complete are often very repetitive. Once a task has been mastered, repeating it may lean to boredom and errors might then occur. This is where computers come in handy Computers are great at repetitive tasks because they never get bored and will never make careless mistakes (only mistakes made by the programmer!)

The For Loop In Java, there are different ways you can repeat a task The first and hardest way is the copy and paste method The method we’ll look at today is the For Loop Structure This structure is good to use when you know or can retrieve how many times something should be repeated

General For Loop Structure for ( ; ; ) { commands you want to repeat you can have more than one command } indentsemicolons repeated commands enclosed in braces

Example of For Loop for (int x=1; x<=10; x++) { g.drawString (“Hello”,10,(x*10)); } Initialization: creates a counter variable and give is a starting value (does not have to be 1) Test Condition: defines a condition that the counter variable checks at the beginning of each loop to be true before doing the loop Increment: this increments the counter variable –x++ is the same as x=x+1 –You can increment OR decrement by any value you want