lecture03-as-given

# lecture03-as-given - Computer Science 111 Lecture 03 Loops...

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

CS111: Slides for Prof. Steinberg ʼ s lecture 1 Lecture 03 Computer Science 111 Computer Science 111 Lecture 03 Loops

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

View Full Document
CS111: Slides for Prof. Steinberg ʼ s lecture 2 Lecture 03 Error Checking Error Checking For homework, for FLOWCHARTS ONLY no need to check inputs for Wrong type of (e.g. 3.4 for an integer) Negative values
CS111: Slides for Prof. Steinberg ʼ s lecture 3 Lecture 03 Multi-way decisions Multi-way decisions Decisions are not always 2-way 1-way: do it or not x < 0 true false x -X

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

View Full Document
CS111: Slides for Prof. Steinberg ʼ s lecture 4 Lecture 03 Multi-way decisions Multi-way decisions Decisions are not always 2-way 3-way: cascaded x < 0 true false Print “negative” x > 0 false true Print “positive” Print “zero”
CS111: Slides for Prof. Steinberg ʼ s lecture 5 Lecture 03 Multi-way decisions Multi-way decisions Decisions are not always 2-way 4-way: cascaded wt > 10 true false Print “too heavy” wt > 1 false true Print “package” Print “impossible” wt > 0 false true Print “letter”

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

View Full Document
CS111: Slides for Prof. Steinberg ʼ s lecture 6 Lecture 03 Multi-way decisions Multi-way decisions Decisions are not always 2-way 4-way: nested wt > 1 true false Print “too heavy” wt > 10 false true Print “package” Print “impossible” wt > 0 false true Print “letter”
CS111: Slides for Prof. Steinberg ʼ s lecture 7 Lecture 03 Multi-way decisions Multi-way decisions Decisions are not always 2-way 4-way: nested wt > 1 true false Print “too heavy” wt > 10 false true Print “package” Print “impossible” wt > 0 false true Print “letter”

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

View Full Document
CS111: Slides for Prof. Steinberg ʼ s lecture 8 Lecture 03 Things to note Things to note Complex program made up of simple primitives More than one way to get the same behavior Nesting
CS111: Slides for Prof. Steinberg ʼ s lecture 9 Lecture 03 Booleans Booleans Can we simplify tests for erroneous input? Yes: combine tests risehour is bad if either riseHour < 0 or riseHour > 23 riseHour<0 or riseHour>23

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

View Full Document
CS111: Slides for Prof. Steinberg ʼ s lecture 10 Lecture 03 Data type Data type All data is stored as groups of bits Datatype: A set of values that can be represented Integers from about -1,000,000,000 to + 1,000,000,000 A mapping from bit patterns to those values Very rarely need to know what the mapping is A set of operations that you can do +, -, *, /, mod
CS111: Slides for Prof. Steinberg ʼ s lecture 11 Lecture 03 Data types Data types ints: whole numbers, range about -1,000,000,000 to +1,000,000,000 doubles: real numbers, 10 -38 to 10 38 with about 7 digits of precision booleans: true and false are the only boolean values

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

View Full Document
CS111: Slides for Prof. Steinberg ʼ s lecture 12 Lecture 03 Booleans Booleans
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 42

lecture03-as-given - Computer Science 111 Lecture 03 Loops...

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

View Full Document
Ask a homework question - tutors are online