Let your program calculate with +, -, *, / and %.

In this video:

  • Adding, subtracting, multiplying and dividing
  • * and / are done before + and -, as in math
  • Parentheses choose what is calculated first
  • Saving a result in a variable: int value = 4 + 6 / 3;
  • Dividing two ints drops the decimal part: 5 / 2 is 2
  • double holds numbers with a decimal part
  • Make at least one side a decimal to divide exactly: 5.0 / 2 is 2.5
  • % gives the remainder of a division and works only with whole numbers: 5 % 2 is 1