Announcements Exam 1 Grades Posted on Blackboard.

Slides:



Advertisements
Similar presentations
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
Advertisements

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.
Topic 03 Control Statements Programming II/A CMC2522 / CIM2561 Bavy Li.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
Announcements Quiz 1 Posted on blackboard Handed Back (and Gone Over)Next Monday “Only a Quiz” Counts 5% of Final Grade Exam 1 Counts 10%
1 CS 105 Lecture 4 Selection Statements Wed, Jan 26, 2011, 6:05 pm.
Repetition Statements repeat block of code until a condition is satisfied also called loops Java supports 3 kinds of loops: while statement – repeats a.
Loop variations do-while and for loops. Do-while loops Slight variation of while loops Instead of testing condition, then performing loop body, the loop.
Copyright 2006 by Pearson Education 1 reading: 4.1 Cumulative sum.
Switch Statement switch (month) { case 9: case 4: case 6: case 11: days = 30; break; case 2: days = 28; if (year % 4 == 0) days = 29; break; default: days.
1 CS 105 Lecture 6 While Loops Wed, Feb 16, 2011, 5:13 pm.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
1 CS 105 Lecture 7 For & Do-While Loops Sun, Feb 27, 2011, 2:16 pm.
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
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
The for Loop Syntax: for ( expression1 ; condition ; expression2 ) statement ; for ( expression1 ; condition ; expression2 ) { statement ; } Same as: expression1.
Announcements Exam 1 Tuesday July minutes 10 % of Total Grade Covers Everything through Lecture 05. –Includes Quiz 1 Topics (terminology, variables,
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
While Loops Programming. COMP102 Prog Fundamentals I: while Loops/Slide 2 Shortcut Assignments l C++ has a set of shortcut operators for applying an operation.
INTRODUCTION SELECTION STATEMENTS -Control Expression -Single/Compound Clauses -Dangling Else MUTLIPLE SELECTION CONSTRUCTS -C/Java Switch -C# Switch -Ada.
Overview of Java Loops By: Reid Hunter. What Is A Loop? A loop is a series of commands that will continue to repeat over and over again until a condition.
Control Structures II: Repetition.  Learn about repetition (looping) control structures  Explore how to construct and use count-controlled, sentinel-controlled,
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CONTROL STATEMENTS LOOPS. WHY IS REPETITION NEEDED?  There are many situations in which the same statements need to be executed several times.  Example:
Building Java Programs Program Logic and Indefinite Loops.
Chapter 9 Control Structures.
CONTROL STRUCTURE Chapter 3. CONTROL STRUCTURES ONE-WAY SELECTION Syntax: if (expression) statement Expression referred to as decision maker. Statement.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
Quiz 1 Exam 1 Next Monday. Nested if Statements if (myGrade >= 80) if (myGrade >= 90) System.out.println(“You have an A!” ); else System.out.println(“You.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Comp1004: Loops and Arrays I Whiles, For and Arrays[]
Follow up from lab See Magic8Ball.java Issues that you ran into.
Sophomore Scholars Java
Slides by Evan Gallagher
Slides by Evan Gallagher
Chapter 9 Repetition.
Chapter 4 Repetition Statements (loops)
Announcements Quiz 1 Posted on blackboard
Chapter 5: Control Structures II
Chapter 6 More Conditionals and Loops
Loop Structures.
Topic 5 for Loops -Arthur Schopenhauer
Repetition-Counter control Loop
CiS 260: App Dev I Chapter 4: Control Structures II.
Java 24th sep /19/2018 CFILT.
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
Announcements Exam 1 Grades Posted on Blackboard.
Chapter 5 Repetition.
Chapter 6 More Conditionals and Loops
Outline Altering flow of control Boolean expressions
Chapter 9 Control Structures.
Selection (if-then-else)
محاضرة 1: مقدمة للمسـاق و مراجعـة للأساسيـات
Announcements Exam 1 Thursday 50 minutes 10 % of Total Grade
Control Statements Loops.
Announcements Exam 1 Thursday Everything through Lab 5 50 minutes
The for Loop Syntax: Same as: for (expression1;condition; expression2)
Module 4 Loops and Repetition 2/1/2019 CSE 1321 Module 4.
A LESSON IN LOOPING What is a loop?
Seating “chart” Front - Screen rows Back DOOR.
Control Statements Loops.
Repetition Statements
Announcements Lab 3 was due today Assignment 2 due next Wednesday
Types of loops definite loop: A loop that executes a known number of times. Examples: Repeat these statements 10 times. Repeat these statements k times.
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
CS 1054 Final Exam Coverage Final exam will cover Chapters 1-8, 10-11
Announcements Exam 1 Grades Posted on blackboard Average: 83.26
Presentation transcript:

Announcements Exam 1 Grades Posted on Blackboard

Iteration Iteration (Looping): Performing a Series of Statements Multiple Times until Some Condition Is Met. Eliminates the Need for Redundant Coding or Method Calls Many Ways to Loop in JAVA

The while Loop Syntax: while (condition) statement; while (condition) { statement; }

while Example final int MAX = 100; int counter = 0; while (counter < MAX) { System.out.println( counter); counter++; }

Example while Loop int numEmployees,curNum = 0; System.out.print(“Enter Number of Employees: “); numEmployees = scan.nextInt(); if (numEmployees > 0) { while (curNum < numEmployees) System.out.println( “Welcome to CorpLand!” ); curNum++; }