//  Age is Relative
//  Last updated:  2008-03-18 by James Alarie <jalarie@umich.edu>
//    http://spruce.flint.umich.edu/~jalarie/
//
//  Each problem will be made up of four section separated by '---' lines.
//  Section #1 states the problem.
//  Section #2 gives the table cell values for the header and all rows.
//  Section #3 shows the age equations as read from the table.
//  Section #4 tells how to solve the problem.

        Problem=new Array();                        // work area
        Problem1=new Array(
          'Eight years from now, Peggy will be as old as Jim is now.',
          'Thirty-four years ago, Jim was half as old as Peggy was last year.',
          'How old are Jim and Peggy now?',
          '---',
          '&nbsp;,-34,-1,Now,+8',
          'Peggy,P-34,P-1,P,P+8',
          'Jim,J-34,J-1,J,J+8',
          '---',
          'P + 8 = J',
          'J - 34 = (P - 1) / 2',
          '---',
          'From equation number 1, substitute &quot;P + 8&quot; for &quot;J&quot; in equation #2 '
          + 'giving &quot;P + 8 - 34 = (P - 1) / 2&quot;',
          'Combine the &quot;8 - 34&quot; to give &quot;P - 26 = (P - 1) / 2&quot;',
          'Multiply by 2 on both sides:&nbsp; 2 * P - 52 = P - 1',
          'Subtract &quot;P&quot; from each side:&nbsp; P - 52 = -1',
          'Add 52 on both sides and you have the &quot;P&quot; value:&nbsp; P = 51',
          'Substitue 51 for &quot;P&quot; in equation #1 to get:&nbsp; 51 + 8 = J',
          'Combine &quot;51 + 8&quot; and see that J = 59',
          '<span class="highlight">&nbsp;Peggy is 51 and Jim is 59&nbsp;&nbsp;<\/span>'
        );
        Problem2=new Array(
          'Tom is as old as William will be in ten years.',
          'In thirty-three years, Tom will be twice as old as William was two years ago.',
          'How old are Tom and William today?',
          '---',
          '&nbsp;,-2,Now,+10,+33',
          'Tom,T-2,T,T+10,T+33',
          'William,W-2,W,W+10,W+33',
          '---',
          'T = W + 10',
          'T + 33 = 2 * (W - 2)',
          '---',
          'Substitute the &quot;T&quot; value from equation number 1 into equation #2 '
          + 'giving &quot;W + 10 + 33 = 2 * (W - 2)&quot;',
          'Combine &quot;10 + 33&quot; to get &quot;W + 43 = 2 * (W - 2)&quot;',
          'Multiply out the &quot;2 * (W - 2)&quot; to see:&nbsp; W + 43 = 2 * W - 4',
          'Subtract &quot;W&quot; from each side:&nbsp; 43 = W - 4',
          'Add 4 on both sides:&nbsp; 47 = W',
          'Substitute this value into equation number 1 to get &quot;T = 47 + 10&quot;',
          'Combine &quot;47 + 10&quot; and see that &quot;T = 57&quot;',
          '<span class="highlight">&nbsp;Tom is 57 and William is 47&nbsp;<\/span>'
        );
        Problem3=new Array(
          'Twenty six years ago, Peggy was half as old as Robert will be next year.',
          'Nine years from now, Peggy will be twice as old as Robert was nineteen years ago.',
          'How old are Peggy and Robert?',
          '---',
          '&nbsp;,-26,-19,Now,+1,+9',
          'Peggy,P-26,P-19,P,P+1,P+9',
          'Robert,R-26,R-19,R,R+1,R+9',
          '---',
          'P - 26 = (R + 1) / 2',
          'P + 9 = 2 * (R - 19)',
          '---',
          'In equation number 2, subtract 9 from each side:&nbsp; P = 2 * (R - 19) - 9',
          'Substitue this &quot;P&quot; value into equation number 1'
          + ':&nbsp; 2 * (R - 19) - 9 - 26 = (R + 1) / 2',
          'Combine the &quot;-9 - 26&quot; for:&nbsp; 2 * (R - 19) - 35 = (R + 1) / 2',
          'Multiply out the &quot;2 * (R - 19)&quot; to give:&nbsp; 2 * R - 38 - 35 = (R + 1) / 2',
          'Combine the &quot;-38 - 35&quot; value:&nbsp; 2 * R - 73 = (R + 1) / 2',
          'Multiply both sides by 2:&nbsp; 4 * R - 146 = R + 1',
          'Subtract &quot;R&quot; from each side:&nbsp; 3 * R -146 = 1',
          'Add 146 to each side:&nbsp; 3 * R = 147',
          'Divide by 3:&nbsp; R = 49',
          'Substitute this back into equation number 2:&nbsp; P + 9 = 2 * (49 - 19)',
          'Combine the &quot;49 - 19&quot; to give &quot;P + 9 = 2 * 30&quot;',
          'Multiply out the &nbsp;2 * 30&quot; part:&nbsp; P + 9 = 60',
          'Subtract 9 from each side:&nbsp; P = 51',
          '<span class="highlight">&nbsp;Peggy is 51 and Robert is 49&nbsp;<\/span>'
        );
        Problem4=new Array(
          'Tom is now the age that Peggy will be in six years.',
          'In eighteen years, Tom will be three times as old as Peggy was twenty-six years ago.',
          'How old are Tom and Peggy today?',
          '---',
          '&nbsp;,-26,Now,+6,+18',
          'Tom,T-26,T,T+6,T+18',
          'Peggy,P-26,P,P+6,P+18',
          '---',
          'T = P + 6',
          'T + 18 = 3 * (P - 26)',
          '---',
          'Substitute the &quot;T&quot; value from equation number 1 into equation '
          + 'number 2:&nbsp; P + 6 + 18 = 3 * (P - 26)',
          'Combine the &quot;6 + 18&quot; to give &quot;P + 24 = 3 * (P - 26)',
          'Multiply out the &quot;3 * (P - 26)&quot; and see:&nbsp; P + 24 = 3 * P - 78',
          'Subtract &quot;P&quot; from each side:&nbsp; 24 = 2 * P - 78',
          'Add 78 to each side:&nbsp; 102 = 2 * P',
          'Divide each side by 2:&nbsp; 51 = P',
          'Substitute this value into equation number 1:&nbsp; T = 51 + 6',
          'Combine &quot;51 + 6&quot; to get:&nbsp; T = 57',
          '<span class="highlight">&nbsp;Tom is 57 and Peggy is 51&nbsp;<\/span>'
        );
        Problem5=new Array(
          'Fifty-eight years ago, Jim was the same age that William was 46 years ago.',
          'In six years, Jim will be five times as old as William was thirty-four years ago.',
          'How old are Jim and William now?',
          '---',
          '&nbsp;,-58,-46,-34,Now,+6',
          'Jim,J-58,J-46,J-34,J,J+6',
          'William,W-58,W-46,W-34,W,W+6',
          '---',
          'J - 58 = W - 46',
          'J + 6 = 5 * (W - 34)',
          '---',
          'Add 58 to both sides of equation number 1:&nbsp; J = W + 12',
          'Substitute this &quot;J&quot; value into equation #2:&nbsp; '
          + 'W + 12 + 6 = 5 * (W - 34)',
          'Combine the &quot;12 + 6&quot; to get:&nbsp; W + 18 = 5 * (W - 34)',
          'Multiply out the &quot;5 * (W - 34)&quot; to give:&nbsp; '
          + 'W + 18 = 5 * W - 170',
          'Subtract &quot;W&quot; from both sides:&nbsp; 18 = 4 * W - 170',
          'Add 170 on both sides:&nbsp; 188 = 4 * W',
          'Divide 4 into both sides:&nbsp; 47 = W',
          'Substitute this into equation #1:&nbsp; J - 58 = 47 - 46',
          'Combine the &quot;47 - 46&quot; values:&nbsp; J - 58 = 1',
          'Add 58 on both sides:&nbsp; J = 59',
          '<span class="highlight">&nbsp;Jim is 59 and William is 47&nbsp;<\/span>'
        );
        Problem6=new Array(
          'Six years from now, Robert will be eleven times as old as William was 42 years ago.',
          'Robert is two years older than William.',
          'How old will each of them be next year?',
          '---',
          '&nbsp;,-42,Now,+1,+6',
          'Robert,R-42,R,R+1,R+6',
          'William,W-42,W,W+1,W+6',
          '---',
          'R + 6 = 11 * (W - 42)',
          'R = W + 2',
          '---',
          'Substitute the &quot;R&quot; value from equation number 2 into '
          + 'equation #1 to give &quot;W + 2 + 6 = 11 * (W - 42)&quot;',
          'Combine the &quot;2 + 6&quot; to give:&nbsp; W + 8 = 11 * (W - 42)', 
          'Multiply out the &quot;11 * (W - 42)&quot; to get '
          + '&quot;W + 8 = 11 * W - 462&quot;',
          'Subtract &quot;W&quot; from each side:&nbsp; 8 = 10 * W - 462',
          'Add 462 to both sides:&nbsp; 470 = 10 * W',
          'Divide by 10 to find Williams current age:&nbsp; 47 = W',
          'Substitute this value into equation number 2 to find &quot;R = 47 + 2&quot;',
          'Combind the &quot;47 + 2&quot; to give Robert\'s current age:&nbsp; R = 49',
          'Notice that the problem wants their ages NEXT year:&nbsp; '
          + '<span class="highlight">&nbsp;Robert will be 50 and William will be 48&nbsp;<\/span>'
        );
        Problem7=new Array(
          'Peggy\'s age last year was half of what William\'s age will be in fifty-three years.',
          'In ten years Peggy will be the age that William will be in forteen years.',
          'How old are they now?',
          '---',
          '&nbsp;,-1,Now,+10,+14,+53',
          'Peggy,P-1,P,P+10,P+14,P+53',
          'William,W-1,W,W+10,W+14,W+53',
          '---',
          'P - 1 = (W + 53) / 2',
          'P + 10 = W + 14',
          '---',
          'Subtract 10 from each side of equation number 2:&nbsp; P = W + 4',
          'Substitute this &quot;P&quot; value into equation number 1:&nbsp; '
          + 'W + 4 - 1 = (W + 53) / 2',
          'Combine the &quot;4 - 1&quot; values:&nbsp; W + 3 = (W + 53) / 2',
          'Multiply both sides by 2:&nbsp; 2 * W + 6 = W + 53',
          'Subtract &quot;W&quot; from each side:&nbsp; W + 6 = 53',
          'Subtract 6 from both sides:&nbsp; W = 47',
          'Substitute this &quot;W&quot; value into equation number 2:&nbsp; P + 10 = 47 + 14',
          'Combine the &quot;47 + 14&quot; values:&nbsp; P + 10 = 61',
          'Subtract 10 from both sides:&nbsp; P = 51',
          '<span class="highlight">&nbsp;Peggy is 51 and William is 47&nbsp;<\/span>'
        );
        Problem8=new Array(
          'Jim is two years older than Tom.',
          'Tom is eight years older than Robert.',
          'Jim\'s age in six years will be thirteen nineths what Robert\'s age was four years ago.',
          'How old are each of them now?',
          '---',
          '&nbsp;,-4,Now,+8',
          'Jim,J-4,J,J+8',
          'Tom,T-4,T,T+8',
          'Robert,R-4,R,R+8',
          '---',
          'J = T + 2',
          'T = R + 8',
          'J + 6 = (13 / 9) * (R - 4)',
          '---',
          'Substitute the &quot;J&quot; value from equation number 1 into equation '
          + 'number 3 to give &quot;T + 2 + 6 = (13 / 9) * (R - 4)&quot;',
          'Substitute the &quot;T&quot; value from equation number 2:&nbsp; '
          + 'R + 8 + 2 + 6 = (13 / 9) * (R - 4)',
          'Combine &quot;8 + 2 + 6&quot; to give &quot;R + 16 = (13 / 9) * (R - 4)',
          'Multiply both sides by 9:&nbsp; 9 * R + 144 = 13 * (R - 4)',
          'Multiply out the &quot;13 * (R - 4)&quot; to give &quot;9 * R + 144 = 13 * R - 52&quot;',
          'Subtract &quot;9 * R&quot; from both sides:&nbsp; 144 = 4 * R - 52',
          'Add 52 to each side:&nbsp; 196 = 4 * R',
          'Divide 4 into each side:&nbsp; 49 = R',
          'Substitute this into equation number 2:&nbsp; T = 49 + 8',
          'Combine the &quot;49 + 8&quot; to find that &quot;T = 57&quot;',
          'Substitute this into equation number 1:&nbsp; J = 57 + 2',
          'Combine the numbers:&nbsp; J = 59',
          '<span class="highlight">&nbsp;Jim is 59, Tom is 57, and Robert is 49&nbsp;<\/span>'
        );
        Problems=8;