# Lab 2: Introduction to Oolong

Before you start:

• The command to assemble your File.j oolong assembly file into a runnable .class file is:
```  oolong File.j
```
This assumes you've got /package/jpower/se209/bin in your path - see lab 1 for how to do this.
• If you get really stuck, you can always write a .java file, compile it into a .class file, and disassemble it back to an oolong assembly file using the gnoloo command. Don;t get into the habit of this, as you won't be able to do this in the lab exam!
• You might like to start by having a look at the factorial example Factorial.j from the lectures; I've modified it slightly so that it expects a command line argument.
• There was a mistake in the notes (which I've now corrected) regarding the order of arguments to subtraction and division; e.g. the operation isub changes the stack as follows:
from: .......... a b
to: .......... a-b
Ditto for division, and for the other types.

### Hello World

... seems a sensible place to start, since it was probably your first Java program. Try and write a program that takes a single command line argument, and prints out "Hello", followed by that argument.

Write a program that takes in three integers as command line arguments - let's call them a, b and c - and prints out the positive root of the quadratic equation that has these as co-efficients.

In case your maths is a bit rusty, you want to print out:

• (-b + Math.sqrt(b*b - 4*a*c)) / (2*a)
Be careful with the square root - that method takes a double as parameter, and returns a double as a result.

I strongly recommend that you do this one step at a time: e.g. first do b*b, then b*b-4*a*c, then ..... Print out the answer each time you add a bit more code - this stuff can be hard to debug! James Power, Dept. of Computer Science Last revised: 27 March 2000