// JavaScript Document
thepage="Scientific Notation"
//updated 10/24/00 added complete solution
//checked with NS47 and IE5
//globals
//updated 12/02/02-netscape 7
attempts=0
coef=0
sign=""
places=0
decimal=0
exponent=0
option=0
theanswer=0
theanswer2=0
theanswer1=0
answered=0
which=0
tried=0
attempts=0
corrt=0
totl=0
whichphrase=0
theans=new Array()
function parts(p1,p2,p3,p4,p5,p6){
	this.p1=p1
	this.p2=p2
	this.p3=p3
	this.p4=p4
	this.p5=p5
	this.p6=p6
}
basichint="It useful to remember that if the number is expressed in proper scientific notation, there are two basic relationships between the exponent and the decimal (non scientific notation) representations of the number.<br>1) For numbers less than one, the exponent is negative and its absolute value is one more than the number of zeros between the decimal and the first non=zero number.Thus, 0.0045 has two zeros between the decimal and the first non-zero number. Therefore the exponent will be -3.<br>2) If the number is greater than or equal to one, the exponent is positive and has a value one less than the length of the number to the left of the decimal.Thus, 256.8 has a length of three to the left of the decimal and will have an exponent of +2.<br><br>"
ansphrase=new Array(10)
ansphrase[1]=new parts("Here you are converting a number less than 1 into scientific notation. First, remember that the exponent will be negative. To convert, move the decimal point "," places to the right. This results in an exponent of "," and a coefficient of ",".")
ansphrase[2]=new parts("Here you are converting a number greater than 1 into scientific notation. First, remember that the exponent will be either zero or positive. To convert, move the decimal point "," places to the left. This results in an exponent of "," and a coefficient of ",".")
ansphrase[3]=new parts("Here you are converting a value in scientific notation which has a positive exponent. First, remember that the result will be a number greater than 1. You move the decimal point in the coefficent "," places to the right. This results in a value of ",".")
ansphrase[4]=new parts("Here you are converting a value in scientific notation which has a negative exponent. First, remember that the result will be a number number less than 1. You move the decimal point in the coefficent "," places to the left. This results in a value of ",".")

function clear(){
	clearansspot()
	attempts=0
	tried=0
	document.forms[0].results.value=""
	document.forms[0].dec.value=""
	document.forms[0].coeff.value=""
	document.forms[0].expon.value=""
}
function startit(){
	clear()
	totl++
	document.forms[0].total.value=totl
	coef=1*(Math.ceil(9*Math.random())+"."+Math.ceil(9*Math.random()))	
	exponent=Math.ceil(8*Math.random())
	places=exponent
	if(Math.random()<.5)sign="-";
		else sign="+";
	exponent=sign+exponent
	decimal=Math.round(10*coef)
	if(sign=="+"){
		for(j=1;j<places;j++)decimal=decimal+"0";
		}
	else{
		leader="0."
		for(j=1;j<places;j++)leader=leader+"0";
		decimal=leader+decimal
		}
	document.forms[0].coeff.value=coef
	document.forms[0].expon.value=exponent
	document.forms[0].dec.value=decimal
	theans[1]=decimal
	theans[2]=coef
	theans[3]=exponent
	setproblem()
}
function setproblem(){
which=Math.ceil(2*Math.random())
if(which==1)
	{
	option=0
	document.forms[0].dec.value=""
	}
if(which==2){
	option=1
	document.forms[0].coeff.value=""
	document.forms[0].expon.value=""
	}
setsolution()
}
function setsolution(){
	theanswer=basichint
	if(which==1){
		if(decimal>=1){
			wp=3
		}
		else{
			wp=4
		}
	theanswer+=ansphrase[wp].p1+places+ansphrase[wp].p2+decimal+ansphrase[wp].p3
	}
	else{
		if(decimal>=1){
			wp=2
		}
		else{
			wp=1
		}
	theanswer+=ansphrase[wp].p1+places+ansphrase[wp].p2+exponent+ansphrase[wp].p3+coef+ansphrase[wp].p4
	}
	//showanswer()
}
function answer(){
	if(tried==1)alert("You've done this one. Get a new problem!");
	else{	
	attempts++
	if(tried==2){totl++;document.forms[0].total.value=totl};
	count=0
	if(option==0){  	
			if(1*document.forms[0].dec.value==1*theans[1])count=1;
		}
	else{	
		if(1*document.forms[0].coeff.value==1*theans[2] & 1*document.forms[0].expon.value==1*theans[3])count=1;
	}
	if(count==1){
		tried=1
		document.forms[0].results.value="correct"
		corrt++
		document.forms[0].correct.value++
	}
	else{
		tried=2
		document.forms[0].results.value="incorrect"
	}
}}