{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

01.0.booleanexpressions

# 01.0.booleanexpressions - Flow of Control The order in...

This preview shows pages 1–2. Sign up to view the full content.

CSE 201 – Elementary Computer Programming 1 Boolean Expressions CSE 201 – Elementary Computer Programming 2 Flow of Control ± The order in which statements in a program are executed is called the flow of control ± So far we have only seen sequential execution: statements execute one after the other in the order in which they appear in the program CSE 201 – Elementary Computer Programming 3 Flow of Control cont. ± Consider the following tasks: ± You want to compute the quotient of two variables but only if the divisor is not zero ± You input some value (e.g., a date) and if it is in the correct format (mm/dd/yyyy) you continue the computation, otherwise you print an error ± Given a grade between 0 and 100, you want to convert the numeric value to a letter grade (e.g., A for grade greater than 90, B for grade between 80 and 90, etc.) ± How can we check these conditions and execute the appropriate piece of code depending on the outcome of the check? CSE 201 – Elementary Computer Programming 4 Divide by Zero Scanner in = new Scanner(System.in); System.out.print(“Enter the dividend: ”); int dividend = in.nextInt(); System.out.print(“Enter the (non-zero) divisor: ”); int divisor = in.nextInt(); if (divisor != 0) { int

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

01.0.booleanexpressions - Flow of Control The order in...

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

View Full Document
Ask a homework question - tutors are online