Control Structures: Part 1

6 downloads 147 Views 448KB Size Report
All Rights Reserved. For use only by instructors in classes for which Java How to Program, Third Edition is the required textbook. 4Control Structures: Part 1. Fig.
chpt_04.fm Page 1 Saturday, August 14, 1999 3:52 PM

1

CONTROL STRUCTURES: PART 1

CHAPTER 4

4 Control Structures: Part 1

Fig. 4.1

add grade to total

total = total + grade;

add 1 to counter

counter = counter + 1;

Flowcharting Java’s sequence structure.

© Copyright 2000 by Prentice Hall. All Rights Reserved. For use only by instructors in classes for which Java How to Program, Third Edition is the required textbook.

chpt_04.fm Page 2 Saturday, August 14, 1999 3:52 PM

CHAPTER 4

CONTROL STRUCTURES: PART 1

2

4.0

Java Keywords

abstract

boolean

break

byte

catch

char

class

continue

case default

do

double

else

extends

false

final

finally

float

for

if

implements

import

instanceof

int

interface

long

native

new

null

package

private

protected

public

return

short

static

super

switch

synchronized this

throw

throws

transient

true

void

volatile

while

try

Keywords that are reserved but not used by Java const Fig. 4.2

goto Java keywords.

© Copyright 2000 by Prentice Hall. All Rights Reserved. For use only by instructors in classes for which Java How to Program, Third Edition is the required textbook.

chpt_04.fm Page 3 Saturday, August 14, 1999 3:52 PM

3

CONTROL STRUCTURES: PART 1

grade >= 60

CHAPTER 4

true

print “Passed”

false

Fig. 4.3

Flowcharting the single-selection if structure.

© Copyright 2000 by Prentice Hall. All Rights Reserved. For use only by instructors in classes for which Java How to Program, Third Edition is the required textbook.

chpt_04.fm Page 4 Saturday, August 14, 1999 3:52 PM

CHAPTER 4

CONTROL STRUCTURES: PART 1

false

print “Failed”

Fig. 4.4

grade >= 60

true

print “Passed”

Flowcharting the double-selection if/else structure.

© Copyright 2000 by Prentice Hall. All Rights Reserved. For use only by instructors in classes for which Java How to Program, Third Edition is the required textbook.

4

chpt_04.fm Page 5 Saturday, August 14, 1999 3:52 PM

5

CONTROL STRUCTURES: PART 1

product