Ch02-2 - • “Terminator” + 2 • “Result of 2 + 3 =...

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

View Full Document Right Arrow Icon
Ch1-1.ppt Java Ch. 2 Data & 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
Ch1-1.ppt Housekeeping Schedule Announcements Questions?
Background image of page 2
Ch1-1.ppt Section 2.2 Variables Things that can change Height Weight Sum Average Weather
Background image of page 3

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

View Full DocumentRight Arrow Icon
Ch1-1.ppt Storing current value Name the storage location Same identifier rules Data type Optional Initial value Scope
Background image of page 4
Ch1-1.ppt Data type Establishes Required space How to encode Legal operations How to perform those operations How to decode
Background image of page 5

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

View Full DocumentRight Arrow Icon
Ch1-1.ppt Declare variables int quantity; double price; char initial; Memory (RAM) Diagrams
Background image of page 6
Ch1-1.ppt Assign variable = value; quantity = 10; price = 19.99; initial = ‘X’;
Background image of page 7

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

View Full DocumentRight Arrow Icon
Ch1-1.ppt Assignment Operator – Right-to-Left total = price + taxAmt; count = count + 1;
Background image of page 8
Ch1-1.ppt Variations int quantity = 10; double price = 19.99; char initial = ‘X’; double height, weight;
Background image of page 9

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

View Full DocumentRight Arrow Icon
Ch1-1.ppt String concatenation “Phineas” + “Taylor”
Background image of page 10
Background image of page 11

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

View Full DocumentRight Arrow Icon
Background image of page 12
Background image of page 13

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

View Full DocumentRight Arrow Icon
Background image of page 14
Background image of page 15

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

View Full DocumentRight Arrow Icon
Background image of page 16
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • “Terminator” + 2 • “Result of 2 + 3 = “ + 2 + 3 • “Result of 2 * 3 = “ + 2 * 3 Ch1-1.ppt Increment Operators num = num + 1; num += 1; num++; // post ++num; // pre • Decrement num = num - 1; num -= 1; num--; // post--num; // pre Ch1-1.ppt Well, why not … num += 2 num -= 3 num *= 4 num /= 5 num %= 6 Ch1-1.ppt Mixing data types • double = double result; – OK • double = integer result; – converted to double • integer = integer result ; – OK • integer = double result – illegal, needs casting Ch1-1.ppt When in doubt • * 1.0 • cast often average = total / count; average = (double) total / count; average = total / (double) count; average = 1.0 * total / count; Ch1-1.ppt First error message only Ch1-1.ppt For Monday Work to catch up to schedule Read 2.2 & 2.3 (& 2.4)...
View Full Document

This note was uploaded on 11/15/2010 for the course COMPSCI Comp 142 taught by Professor Topham during the Spring '06 term at Shoreline.

Page1 / 16

Ch02-2 - • “Terminator” + 2 • “Result of 2 + 3 =...

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

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