CH4 – Math Methods

  1. Open DrJava and expand the Interactions pane.
  2. Type the following, remember DrJava interprets statements through the semi-colon, typing a variable name and pressing the return key is interactively telling the Interactions pane to echo the value.
> double root = Math.sqrt(17.0);
> root
4.123105625617661
> double angle = 1.5;
> double height = Math.sin(angle);
> height
0.9974949866040544
  1. Type the following three lines in the Interactions pane.
> double degrees = 90;
> double angle = degrees/180.0 * Math.PI;
> angle
1.5707963267948966
  1. Type the following two lines in the Interactions pane.
> long x = Math.round(Math.PI * 20.0);
> x
63