Set up p. 36 for HW and p. 37 for Cornell notes · Table of Contents Date(s) Title/Topic Page #s...
Transcript of Set up p. 36 for HW and p. 37 for Cornell notes · Table of Contents Date(s) Title/Topic Page #s...
Table of ContentsDate(s) Title/Topic Page #s
9/11 2.4 Primitive Data Types, 2.5 Arithmetic Expressions
36-37
Set up p. 36 for HW and p. 37
for Cornell notes
36 37
HW
2.4 Primitive Data Types,
2.5 Arithmetic ExpressionsAP Test Questions
APTestQuestionFriday
Primitive DataThere are exactly eight primitive data types in JavaFour of them represent integers:> byte, short, int, long
Two of them represent floating point numbers:> float, double
One of them represents characters:> char
And one of them represents boolean values:> boolean
Only three are in the AP subset: int, double, and boolean
Numeric Primitive Data
BooleanA boolean value represents a true or
false conditionA boolean also can be used to represent any two states, such as a light bulb being on or offThe reserved words true and false
are the only valid values for a boolean type
boolean done = false;
CharactersA char variable stores a single character from
the Unicode character setA character set is an ordered list of characters, and each character corresponds to a unique numberThe Unicode character set uses sixteen bits per character, allowing for 65,536 unique charactersIt is an international character set, containing symbols and characters from many world languagesCharacter literals are delimited by single quotes:
'a' 'X' '7' '$' ',' '\n'
Characters
p. 37
primitive
data types
there are 8 but only 3 on
AP test (int, double, boolean)
2.4 Primitive Data Types,
2.5 Arithmetic Expressions
integer
floating point
(aka decimal)
true or
false
Division and Remainder
Operator PrecedenceOperators can be combined into complex expressions
result = total + count / max - offset;
Operators have a well-defined precedence which determines the order in which they are evaluatedMultiplication, division, and remainder are evaluated prior to addition, subtraction, and string concatenationArithmetic operators with the same precedence are evaluated from left to rightParentheses can be used to force the evaluation order
Operator Precedence
Assignment Revisited
Assignment Revisited
p. 37
remainder
operator
also known as modulus
% symbol
2.4 Primitive Data Types,
2.5 Arithmetic Expressions
ex: 17%4
division
examples10/4 10.0/4 10/4.0
p. 37
operator
precedence
hierarchy
*, /, and % are performed
before + and -
done left to right
you can use parentheses to
change the order
2.4 Primitive Data Types,
2.5 Arithmetic Expressions
APTestQuestionFriday
HW - p. 106 Self-Review 2.12, 2.13
p. 107 Mult Choice 2.1-2.5 do on p. 36 in NB
Summary - at bottom of p. 37
Why are the answers to 5/2 and
5.0/2 different?
Chapter2–Lab1
NamesandPlaces
ATableofStudentGrades
*due next Wednesday
*turn both .java files in
on Google Classroom