calculator. you can think of a calculator as an infinite sequence of symbols, where the nth symbol is the nth button you clicked. You do NOT store the full sequence since when you incorporate operators you are really doing evaluations so 2+*3=4+5 is equivalent to 2*3, display, (delete saved symbols) 4+5 and 2+3/4 is equivalent to 2+3 (display and store 5, delete other symbols) 5/4, display and store result. (chaining) initialize: two number boxes num1 num2 to 0; (note, always display num1, our computations are to be stored here). first operand entered during current formula=false operator entered in current formula=false second operand (number2)entered in current=false enable_number1_mod=true (when this is disabled, number2 is enabled by default mod here refers to concatenation) equals_just_entered=true;// imagine you hit = when you open your calculator. // it should be doing nothing, right? (nonequals) arithm operator value="+";(because 0+0=0, good initial choice). input: button // +2 is really equivalent to 0+2; if button is arithm operator{ if equals_just_entered{ second_operand_entered=false; } else if arithm op.already previously entered in current formula if number2 already entered in current formula{ compute number(operator value)number2 store result in number1 second_operand_entered= false (note, not the operator flag)} operator_value = button; enable_number1_mod=false; equals_just_entered=false; } else (has to be =) if you have entered number2 in current formula number1=number1(op)number2 else number1=number1 op number1 equals_just_entered=true; first_operand_entered=true; why do we need the equals_just_entered flag? because we know that if we hit a number after an =, the whole problem is reset example 2x3===4+5+6==1 (is what?) note that if i do 2x3=+4 it DOESNT reset the calculator. this comes into play in the other big case: digits input: digit if equals_just_entered: reset the global variables (this will start a new formula) num1=digit; else if (enable_number1_mod) concatenate to number1 else if (second_operand entered_) concatenate to number2 else number2=digit; second_operand_entered=true; equals_just_entered=false;//FOR ALL CASES HERE array1=document.getElementsByTagName("p"); node_max=array1[0]; for(i=0;inode_max.innerHTML.length); node_max=array1[i]; } alert(node_max.innerHTML); arrayimg=document.getElementsByTagName("img"); for(i=0;i