LAB 3 - Introduction to DrJava

Lab Exercises

Topics                                                 Lab Exercises

Installing DrJava

Starting DrJava

Math Operators

Printing Results of a Statement

Data Types in Math Expressions

 

Exercises

Installing DrJava

a)      Make sure you have Java 1.5 or above installed on your computer (http://www.java.sun.com)

b)      Install DrJava (http://drjava.org)

c)      Add the Java classes that come with book to the extra classpaths for DrJava. In the CSU labs, the path is Y:\APPS\summers\bookClasses [This is the tutorials folder on the desktop]. It will be different on your own computer.

 

Starting DrJava

  1. Locate the Dr. Java icon on the desktop (or in Y:\APPS\summers\) and launch it
  2. Wait while Dr. Java loads

  1. The top-left pane is the files pane; the top-right pane is the definitions pane; the bottom pane is the interaction pane.

Math Operators

 

Try typing the following into the interaction pane:

 

> 34 + 56

90

> 26 - 3

23

> 3 * 4

12

> 4 / 2

2

 

Printing Results of a Statement

 

Try typing the following into the interaction pane:

 

> System.out.println(34 + 56);

90

> System.out.println(26 - 3);

23

> System.out.println(3 * 4);

12

> System.out.println(4 / 2);

2

> System.out.println(9 % 4);

1

> System.out.println(9 / 5 * -3 + 32);

29

> System.out.println(3 + 2 * 4);

11

> System.out.println((3 + 2) * 4);

20

 

Data Types in Math Expressions

 

Try typing the following into the interaction pane:

 

> System.out.println(1.0/2.0);

0.5

> System.out.println(1/2);

0

Be sure to review Dr. Java (http://www.drjava.org/) [ tutorial at http://csc.ColumbusState.edu/summers/NOTES/1301/1301-PPT/DrJava-Tutorial.ppt]

Submit answers to

a) 45 + 43 % 5 * (23 * 3 % 2);

b) 2.8 (pg. 36),

c) 2.9 (pg. 36)

            through the DropBox in WebCT.