Decision statements. - They can use logic to arrive at desired results

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
Fundamental Programming Structures in Java: Control Flow, Arrays and Vectors.
8-May-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
Introduction to Control Statements Presented by: Parminder Singh BCA 5 th Sem. [ Batch] PCTE, Ludhiana 5/12/ Control Statements.
CS 106 Introduction to Computer Science I 02 / 18 / 2008 Instructor: Michael Eckmann.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
Additional control structures. The if-else statement The if-else statement chooses which of two statements to execute The if-else statement has the form:
Nested For Loops It is also possible to place a for loop inside another for loop. int rows, columns; for (rows=1; rows
16-Jun-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Introduction to Computers and Programming for Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to.
Loops –For For Reading for this Lecture, L&L, Part of 5.8.
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Loops II Lecture 13, Thu Feb
University of British Columbia CPSC 111, Intro to Computation 2009W2: Jan-Apr 2010 Tamara Munzner 1 Loops III Lecture 19, Wed Mar
1 Repetition structures Overview while statement for statement do while statement.
Introduction to Programming G51PRG University of Nottingham Revision 2 Essam Eliwa.
Control Structures II. Why is Repetition Needed? There are many situations in which the same statements need to be executed several times. Example: Formulas.
Lecture 10 Instructor: Craig Duckett. Assignment 2 Revision TONIGHT DUE TONIGHT Wednesday, August 5 th Assignment 3 NEXT DUE NEXT Monday, August 10 th.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
The switch StatementtMyn1 The switch Statement Sometimes there can be a multiple-choice situation, in which you need to execute a particular set of statements.
October 28, 2015ICS102: For Loop1 The for-loop and Nested loops.
Repetition Statements while and do while loops
1-Dec-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
J AVA P ROGRAMMING 2 C H 03: C ONTROL STATEMENTS if, for loop (review) switch, while, do while break, continue Fall Java Programming.
Introduction to Computing Concepts Note Set 15. JOptionPane.showMessageDialog Message Dialog Allows you to give a brief message to the user Can be used.
The Assignment operator tMyn1 The Assignment Operator The result of a calculation can be stored in a variable using the assignment operator =. Because.
CONTROL STATEMENTS LOOPS. WHY IS REPETITION NEEDED?  There are many situations in which the same statements need to be executed several times.  Example:
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
For Loop Tips And Tricks
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
Chapter 9 Control Structures.
CONTROL STRUCTURE. 2 CHAPTER OBJECTIVES  Learn about control structures.  Examine relational and logical operators.  Explore how to form and evaluate.
CSCI S-1 Section 4. Deadlines for Homework 2 Problems 1-8 in Parts C and D – Friday, July 3, 17:00 EST Parts E and F – Tuesday, July 7, 17:00 EST.
CONTROL STRUCTURE Chapter 3. CONTROL STRUCTURES ONE-WAY SELECTION Syntax: if (expression) statement Expression referred to as decision maker. Statement.
Methods.
Arrays in java Unit-1 Introduction to Java. Array There are situations where we might wish to store a group of similar type of values in a variable. Array.
Loops and Logic. Making Decisions Conditional operator Switch Statement Variable scope Loops Assertions.
CS0007: Introduction to Computer Programming The for Loop, Accumulator Variables, Seninel Values, and The Random Class.
WAP to find out the number is prime or not Import java.util.*; Class Prime { public static void main(string args[]) { int n,I,res; boolean flag=true;
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING For Loop.
Structured Programming Structured Programming is writing a program in terms of only 3 basic control structures: sequence selection repetition We have already.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Lesson 7 Iteration Structures. Iteration is the third control structure we will explore. Iteration simply means to do something repeatedly. All iteration.
Chapter 7 Control Structures. Java has very flexible three looping mechanisms. You can use one of the following three loops:  while Loop  do...while.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
Session Three Review & Conditional Control Flow. Java File Hierarchy Projects Packages Classes Methods.
Slides by Evan Gallagher
Slides by Evan Gallagher
Chapter 9 Repetition.
Chapter 2 Clarifications
using System; namespace Demo01 { class Program
Chapter 5 Repetition.
The for-loop and Nested loops
LRobot Game.
Chapter 9 Control Structures.
An Introduction to Java – Part I, language basics
In this class, we will cover:
Java Language Basics.
class PrintOnetoTen { public static void main(String args[]) {
Lecture Notes – Week 2 Lecture-2
In this class, we will cover:
Repetition Statements
Review of Previous Lesson
22C:21 Problem 2.3 Solution Outline.
Loops CGS3416 Spring 2019 Lecture 7.
Control Structure.
Control Statements:.
Presentation transcript:

Decision statements. - They can use logic to arrive at desired results Decision statements - They can use logic to arrive at desired results - They can go in loops over and over until they come to the end of a specified group of numbers - There are four or more types of decision statements - they can be nested (one inside another or so)

For Loops For loops have 4 parts - Often For Loops are inside a method for ( int i = 1; i < 5; i ++) { System.out.println( i ); } 1) Initialize the variable 2) The Boolean test 3) the statements to perform 4) increment or decrement - Then go/loop back to the Boolean test and repeat - Continue looping until the variable gets a“false” at the Boolean test - stop immediately and continue to the program’s next step.

class ForLoopExample {. public static void main(String args[]) class ForLoopExample { public static void main(String args[]) { for(int i=10; i>1; i--) { System.out.println("The value of i is: "+i); } } }