Code examples MakingCircles.java Circle.java Loopy.java

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

Control Structures.
While loops.
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
Control Structures Selections Repetitions/iterations
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.
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
Fundamental Programming Structures in Java: Control Flow, Arrays and Vectors.
Introduction to Computers and Programming Lecture 9: For Loops New York University.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
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.
1 Parts of a Loop (reminder) Every loop will always contain three main elements: –Priming: initialize your variables. –Testing: test against some known.
Introduction to Computers and Programming for Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to.
Repetition Statements repeat block of code until a condition is satisfied also called loops Java supports 3 kinds of loops: while statement – repeats a.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
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.
Flow of Control Loops – Chapter 3.2. Java Loop Statements: Outline the while Statement the do-while Statement the for Statement.
1 Fall 2007ACS-1903 Ch 4 Loops and Files Increment & decrement statements while loop do-while loop Other topics later on …
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
Do … while ( continue_cond ) Syntax: do { stuff you want to happen in the loop } while (continue_condition);
Repetition Statements.  Often it is necessary to repeat statements many times  Java has two ways of doing this  while statements  for statements.
ㅎㅎ 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.
Loops ISYS 350. Compute the sum of a list of numbers: Example: 5, 2, 10, 8, 4 Process: Sum= 0 Get a number from the list Sum = Sum + the number Repeat.
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.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Repetition Statements (Loops) The do while Loop The last iteration structure in C++ is the do while loop. A do while loop repeats a statement or.
Repetition Control Structure. Introduction Many applications require certain operations to be carried out more than once. Such situations require repetition.
CSC 107 – Programming For Science. Today’s Goal  Know how to use and write for loops  Explain why to use for, while, & do-while loops  Convert between.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
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.
1 Fall 2009ACS-1903 Ch 4 Loops and Files while loop do-while loop for loop Other topics later on …
While ( number
Loops ISYS 350. Two Types of Loops while loop for loop.
Repetition Statements b Repetition statements allow us to execute a statement multiple times repetitively b They are often simply referred to as loops.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
if ( condition ) statement; if is a Java reserved word The condition must be a boolean expression. It must evaluate to either true or false.
Follow up from lab See Magic8Ball.java Issues that you ran into.
Introduction to Classes and Objects Shirley Moore CS 1401 Spring 2013 cs1401spring2013.pbworks.com April 23, 2013.
Chapter 9 Repetition.
Chapter 4 Repetition Statements (loops)
Loops in Java.
Java's for Statement.
Review If you want to display a floating-point number in a particular format use The DecimalFormat Class printf A loop is… a control structure that causes.
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
Chapter 5 Structures.
all loops initialization – set up the loop
Chapter 5 Repetition.
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Iteration with While You can say that again.
MSIS 655 Advanced Business Applications Programming
LRobot Game.
Chapter 9 Control Structures.
Lecture Notes – Week 3 Lecture-2
MSIS 655 Advanced Business Applications Programming
Chapter 8: More on the Repetition Structure
Introduction to Objects & Classes
Flow of Control.
Relational Operators.
Seating “chart” Front - Screen rows Back DOOR.
Repetition Statements (Loops) - 2
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.
Looping and Repetition
Presentation transcript:

Code examples MakingCircles.java Circle.java Loopy.java Loops Code examples MakingCircles.java Circle.java Loopy.java

UML Diagram bigSpot littleSpot radius: 6 radius: 2 Circle Name of class Data (attributes) Methods of the class radius: double Circle(double radius) getRadius(): double getArea(): double getCircumference(): double bigSpot littleSpot radius: 6 radius: 2 Circle(double radius) getRadius(): double getArea(): double getCircumference(): double Circle(double radius) getRadius(): double getArea(): double getCircumference(): double

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?

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 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 Another name is counted loop – You typically will execute a for loop based on some counter.