Chapter 4: Fundamental Data Types
Arithmetic Operators
- Addition: +
- Subtraction: -
- Multiplication: *
- Division: /
- Remainder of Integer Division (Modulo): %
- Note: parentheses can be used to overcome precedence
Built-In Math Class
- Contains many built-in static methods such as Math.sqrt(double)
Roundoff Errors
- Computers represent numbers with an underlying binary representation.
While some numbers can be represented exactly (e.g. 0.5), others
can not (e.g. 0.35). This in turn can lead to roundoff errors
in computations.
Lecture Code
The program below calculates compound interest using the equation
found here.