var i=readInt var j=readInt while (i != j) if (i > j) i = i - j else j = j - i println(i)might also be written
var i=readInt var j=readInt while (i != j) if (i > j) i = i % j else j = j % i println(i)Does this program compute the same result? If not, can you fix it? Under what circumstances would you expect one or the other to be faster?
According to good programming style the internal data of the ship is hidden from the user, so that the user can only manipulate the ship using its accessors. What should you do with erroneous parameters? Equip the vessel with a toString() method to make it easy to print out the state of the ship.
The program will print out the state of the vessel after each operation. In this exercise you need not be prepared to non-numerical input.