24.5:

/**
 The complex class is from the 2004Fa solution
*/
class Complex {
    private double r, i;

    public Complex(double r, double i) {
        this.r = r;
        this.i = i;
    }

    public Complex add(Complex c) {
        return new Complex(r + c.r , i + c.i);
    }

    public String toString() {
        return r + " + " + i + "i";
    }
}

class P24_5
{
    private static Complex newRandomComplex()
    {
        return new Complex(Math.random(), Math.random());
    }
    
    public static void main(String[] args)
    {
        final int SIZE = 10;
        
        Complex[] randomComplexNumbers = new Complex[SIZE];
        for (int i = 0; i < SIZE; ++i)
            randomComplexNumbers[i] = newRandomComplex();
    }
}

-----------------------------------------------------
24.6:

class P24_6
{
    static final int LETTERS = 26;
    
    static char[] rotate(int shift)
    {
        char[] shifted = new char[LETTERS];
        
        for (int pos = 0; pos < LETTERS; ++pos)
            shifted[pos] = (char)('a' + ((pos - shift + LETTERS) % LETTERS));
        
        return shifted;
    }
    
    
    public static void main(String[] args)
    {
        System.out.println(rotate(3));
        System.out.println(rotate(0));
        System.out.println(rotate(26));
        System.out.println(rotate(5));
    }
}

-----------------------------------------------------
24.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();
    } // main
    
    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 slice = 0; slice < x.length; ++slice) {
            for (int row = 0; row < x[slice].length; ++row) {
                for (int col = 0; col < x[slice][row].length; ++col)
                    System.out.print(x[slice][row][col] + " ");
                System.out.println();
            }
            System.out.println();
        }
    }
}

-----------------------------------------------------
24.13:

class P24_13
{
    static boolean find2(int[] array)
    {
        for (int val: array)
            if (val == 2)
                return true;
        return false;
    }
    
    public static void main(String[] args)
    {
        int[] a = {1, 2, 3};
        
        int sum = 0;
        for (int val: a)
            sum += val;
        System.out.println("The sum is:" + sum);
        
        find2(a);
    }
}

