Statements can use mathematical expressions by employing the operators
%. You use these operators to crunch numbers throughout your Java programs.
An addition expression in Java uses the
+ operator, as in these statements:
double weight = 205;weight = weight + 10;
The second statement uses the
+ operator to set the
weight variable equal to its current value plus 10. A subtraction expression uses the
weight = weight - 15;
This expression sets the
weight variable equal to its current value minus 15.
A division expression uses the
weight = weight / 3;
This sets the
weight variable to its current value divided by 3.
To find a remainder from a division expression, use the
% operator (also called ...