Lab 2: Introduction to Oolong


Before you start:

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.

Quadratics

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:

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!

Solution: Quadratic.j

Conditionals

When you get the quadratic one done, you might like to try a small example using conditionals: write a program that accepts three integers as command line parameters, and prints out the biggest one.

Solution: Max3Int.j


NUIM Logo James Power,
Dept. of Computer Science
Last revised: 27 March 2000