Matrix Calculator in Java