# BeanShellTutorial:2 Arithmetic

## Arithmetic

In BeanShell you also have the option of working with "loosely typed" variables. That is, you can simply omit the types of variables that you use (both primitives and objects). Now, let's try to use BeanShell as a calculator. We will calculate 3*8/6:

# Numbers and Math

You can also do some calculations using elementary functions. Math functions are imported by BeanShell automatically and you will need only to call the package name Math. Let's try to use BeanShell as a calculator. We will calculate $\sqrt(100))$:

We have added the "Math" package name which is imported automatically by BeanShell. Let us consider a logarithmic function:

Exercise: Change 100 to some other number and check the output |

## Default Imports

In the previous example, we called the "Math" package, which belongs to Java ** java.lang** package.
This package is imported automatically.
By default, common Java core and extension packages are imported for you. They are, in the order in which they are imported:

- javax.swing.event
- javax.swing
- java.awt.event
- java.awt
- java.net
- java.util
- java.io
- java.lang

### Exercises:

- Calculate logarithm of 10
- Calculate the absolute values of -100