25.5~~~~~~~~~~~~~~~~~~

class Complex
{
	private double re, im;

	public Complex(double r, double i)
	{
		re = r;
		im = i;
	}

	public Complex add(Complex other)
	{
		return new Complex(re + other.re, im + other.im);
	}

	public String toString()
	{
		String result = "";

		if (im == 0)
		{
			result = (new Double(re)).toString();
		}
		else if (im < 0)
		{
			result = re + "-i" + Math.abs(im);
		}
		else
		{
			result = re + "+i" + im;
		}

		return result;
	}
}

public class TestCurrent
{
	public static final int BOUND = 10000;

	// generates a random complex object, within [-BOUND, BOUND]
	public static Complex generateRandomComplexNo()
	{
		double re = (Math.random()*BOUND) - BOUND/2;
		double im = (Math.random()*BOUND) - BOUND/2;

		return new Complex(re, im);
	}

	public static void main(String[] args)
	{
		// the array of complex objects
		Complex[] array = new Complex[10];

		// using a for loop to generate them
		for (int i = 0; i < 10; i++)
		{
			array[i] = generateRandomComplexNo();
			System.out.println(array[i]);
		}
	}
}


25.6~~~~~~~~~~~~~~~~~~~~~~

	public static char[] rotate(int shift)
	{
		if (shift > 26 || shift < 0)
		{
			System.out.println("Invalid shift range");
			System.exit(1);
		}

		// create the standard array
		int size = 'z' - 'a' + 1;

		char[] alphabet = new char[size];

		// generate the tail, meaning the alphabet that
		// is in normal order
		for (char c = 'a'; c <= 'z' - shift; c++)
		{
			alphabet[c + shift - 'a'] = c;
		}

		// generate the rotated "head" part of the alphabet
		for (int i = 0; i < shift; i++)
		{
			alphabet[shift - i - 1] = (char) ('z' - i);
		}

		return alphabet;
	}


25.10~~~~~~~~~~~~~~~~~~~~~~~~

public class aoa3d
{
	private static int[][][] x;

	public static int myRandom(int low, int high)
	{
		return (int) (Math.random() * (high - low + 1)) + low;
	}

	public static void main(String[] args)
	{
		createArray();
		printArray();
	}

	private static void createArray()
	{
		x = new int[2][][];
		for (int d1 = 0; d1 < x.length; d1++)
		{
			x[d1] = new int[2][];
			for (int d2 = 0; d2 < x[d1].length; d2++)
			{
				x[d1][d2] = new int[myRandom(1, 2)];
				for (int d3 = 0; d3 < x[d1][d2].length; d3++)
				{
					x[d1][d2][d3] = myRandom(0, 1);
				}
			}
		}
	}

	private static void printArray()
	{
		for (int d1 = 0; d1 < x.length; d1++)
		{
			// printing one 2D array
			System.out.println("2D array number " + (d1 + 1) + ":");

			for (int d2 = 0; d2 < x[d1].length; d2++)
			{
				for (int d3 = 0; d3 < x[d1][d2].length; d3++)
				{
					System.out.print(x[d1][d2][d3]);
					System.out.print("\t");
				}
				System.out.println("\n"); // add a new line for visibility
			}
		}
	}
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~