lecture03-as-given

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

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

View Full Document Right Arrow Icon
CS111: Slides for Prof. Steinberg ʼ s lecture 1 Lecture 03 Computer Science 111 Computer Science 111 Lecture 03 Loops
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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”
Background image of page 4
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”
Background image of page 5

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

View Full DocumentRight Arrow Icon
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”
Background image of page 6
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”
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
CS111: Slides for Prof. Steinberg ʼ s lecture 12 Lecture 03 Booleans Booleans
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online