Week6Chap4-Iv-Section2

Week6Chap4-Iv-Section2 - Chapter 4 Control Statements in...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Janaka Balasooriya CSE 110, Arizona State University Chapter 4 Control Statements in Java Repetition
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
From the Last Lecture Janaka Balasooriya CSE 110, Arizona State University • Repetition control structure allows us to execute a block of statement (s) several times. • Java provide three forms of repetition while loop for loop do while loop while (condition) { // perform set of operation } Loop Condition Check Java Statement (s) True False
Background image of page 2
While loop in Java Janaka Balasooriya CSE 110, Arizona State University There are several ways we can write the condition statement 1. Counter controlled 2. Sentinel controlled Counter controlled counter = 0 while(counter < 10) { System.out.println(“hello”); counter ++; } Sentinel controlled int num; num = scan.nextInt(); while(num != -999) { System.out.println(c); num = scan.nextInt(); }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Janaka Balasooriya CSE 110, Arizona State University If (number != -999) Add positive number and negative numbers
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 12

Week6Chap4-Iv-Section2 - Chapter 4 Control Statements in...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online