APCS Quiz 3 Set

¡Supera tus tareas y exámenes ahora con Quizwiz!

x*=

x *= y is the same as x = x * y

+=

x += y is the same as x = x + y

x-=

x -= y is the same as x = x - y

x/=

x /= y is the same as x = x / y

Check if any number is evenly divisible by the other

you can use it to check if any number is evenly divisible by another (num1 % num2 == 0)

Double Plus Operator (++)

The ++ operator is used to add one to the current value: x++ is the same as x = x + 1.

Double Minus Operator(--)

The -- operator is used to subtract one from the current value: y-- is the same as y = y - 1.

What is the result of 3 % 8?

Correct! 8 goes into 3 no times so the remainder is 3. The remainder of a smaller number divided by a larger number is always the smaller number!

Learning Objective Two(Skill)

Evaluate numerical expressions containing the modulus operator (%)

Check if Number is Even

If Any number mod 2 equals 0 it is even num % 2 == 0 is even

Check if Number is odd

If Any number mod 2 equals 1 it is odd num % 2 == 1 is odd

Operators

Java uses the standard mathematical operators for addition (+), subtraction (-), multiplication (*), and division (/). Java uses (==) to test if the value on the left is equal to the value on the right and (!=) to test if two items are not equal. But, the percent sign operator (%) is the modulus or remainder operator.

Modulus(%)

The modulus is used to find the remainder after dividing two numbers. For example: 9%2= 1 10%10=0 5%4=1 etc.

Order of Modulus

The modulus operator (%) returns the remainder after you divide the first number by the second number.

Last Digit for Number

Use it to get the last digit from an integer number (num % 10 = last digit on right).

Minutes Left

Use it to get the number of minutes left when you convert to hours (num % 60).

learning Objective One(Knowledge)

What is the modulus operator (%)?


Conjuntos de estudio relacionados

Ch 11: Skull and Cranial Bones ~ Workbook

View Set

Chapter 12 Psychological Disorders

View Set

Mankiw Macroeconomics Chapters 1-5

View Set

SmartBook Assignment Chapter 14: Chemical Kinetics

View Set

ISM Ch. 4 & 6The CPU stores the results of computations in ________.

View Set

Government Funded Health Insurance Plans

View Set

Spanish Recipricos and Reflexivos

View Set

Environmental Biology/BIOL-2306/Chapter 01

View Set