// JavaScript Document
thepage="Exponents(1)"
//globals
refnumber=2
attempts=0
tried=0
totl=0
corrt=0
instruct=0
problem=""
thequest=theanswer=""
theanswr=""
introphrase="If the term below is evaluated and the results expressed in proper scientific notation, what is the value of the resultant exponent?<br><br>"
ansphrase=new Array()
ansphrase[0]=new Array("Since this is a division problem, the 'preliminary' exponent is the denominator exponent subtracted from the numerator exponent:<br>","<br>In this case the numerator coefficient is "," than the denominator coefficient. Thus, the final exponent is:<br>")
ansphrase[1]=new Array("Since this is a multiplication problem, the 'preliminary' exponent is the sum of the two exponents:<br>","<br>In this case the product of the coefficients is "," than ten. Thus, the final exponent is:<br>")

function startit(){
	clear()
	totl++
	document.forms[0].total.value=totl
	c1=0
	c2=0
	while(c1<1){c1=Math.ceil(600*Math.random())/100}
	while(c2<1){c2=Math.ceil(600*Math.random())/100}
	e1=Math.ceil(20*Math.random())
	if(Math.random()>.5){e1=-e1}
	e2=Math.ceil(30*Math.random())
	if(Math.random()>.5){e2=-e2}
	term1=c1+"*10<sup>"+e1+"</sup>"
	term2=c2+"*10<sup>"+e2+"</sup>"
	if(Math.random()<.5){
    		operator="<b>/</b>"
    		key=0
	}
	else{
    	operator=" x "
    	key=1
	}
	thequest=introphrase+term1+operator+term2
	getvalue(c1,c2,e1,e2,key)
	buildanswer(c1,c2,e1,e2,key)
	showquest(thequest)
}
function getvalue(c1,c2,e1,e2,key){
	if(key==1){
    	if(c1*c2>=10){theanswr=e1+e2+1}
    	else{theanswr=e1+e2}
}
else{
    	if(c1>c2){theanswr=e1-e2}
    	else{theanswr=e1-e2-1}
	}
	}
function buildanswer(c1,c2,e1,e2,key){
	theanswer=ansphrase[key][0]
	if(key==0){
		theanswer+=e1+"-"+e2+"="+(e1-e2)+ansphrase[0][1];
		c1>c2?theanswer+=(" greater "+ansphrase[0][2]):theanswer+=(" less "+ansphrase[0][2]);
		c1>c2?theanswer+=(e1-e2):theanswer+=((e1-e2)+"-1="+(e1-e2-1));
	}
	else{
		theanswer+=e1+"+"+e2+"="+(e1+e2)+ansphrase[1][1];
		(c1*c2>10)?theanswer+=(" greater "+ansphrase[1][2]):theanswer+=(" less "+ansphrase[1][2]);
		(c1*c2>10)?theanswer+=((e1+e2)+"+1="+(e1+e2+1)):theanswer+=(e1+e2);
	}
}

function answer(ans){
	attempts++
	if(tried==1)alert("You've already done this one. Get a new problem");
	else{
	if(tried==2){totl++;document.forms[0].total.value=totl};
	if(ans==theanswr){
		document.forms[0].results.value="correct"
		corrt++
		document.forms[0].correct.value=corrt
		tried=1
	}
	else{
		document.forms[0].results.value="incorrect"
		tried=2
	} 
}}
