AP Computer Science Lesson Introductory Java Language Features (2)

Words
81
Reading
1 min
Listen
Play
9y

Notes Intro Java Language Features - Operators 8/16

alt


####Arithmetic Operators:

"+"Addition-
"-"Subtraction-
"*"Multiplication-
"/"Division-
"%"Mod (remainder)Ex. 11 % 8 = 3

** Keep in mind, if you use int for 5/2... It will give you an integer! So, use double as its type.


Relational Operators:

==equal toEx. if (x == 100)
!=not equal toEx. if (x != 100)
>greater than
<less than
>=greater than or equal to
<=less than or equal to

** Use these when you may need to use different operations to different types of numbers.


Logical Operators:

alt
** AND means both have to be true.
** OR means one has to be true.

Truth Tables

alt


Assignment Operators:

=x = 2-
+=x += 4this means x = x + 4
-=x -= 4this means x = x - 4
*=x *= 4this means x = x * 4
/=x /= 4this means x = x / 4
%=x %= 4this means x = x % 4

Increment and Decrement Operators:

++i++means i = i + 1
--i--means i = i - 1

** Here is a mathematical example where we could use this:
alt


A mathematical program:

alt
Output (what the user would see):
Solving 5+3*2-2^2:
7


Question for the Students

Make a program with the output:
Hello World.
My name is ______.
My favorite movie is ______.

Answer:
alt


Thank you for viewing Steemers! I am happy to provide my lesson plans for you!


alt

AP Computer Science Lesson Introductory Java Language Features (2) | Ecency