thepage="Percent yield(135)"
refnumber=175
attempts=0
//updated 12/2/02-netscape 7
totl=0
corrt=0
first=0
second=0
theanswr=0
tried=0
theanswer=""
qphrase=new Array()
seq=new Array()
qphrase[0]=new Array("For the balanced equation shown below, if the reaction of "," grams of "," produces "," grams of ",", what is the percent yield?")
qphrase[1]=new Array("For the balanced equation shown below, if the reaction of "," grams of "," produces a ","% yield, how many grams of "," would be produced ?")
ansphrase=new Array()
ansphrase[0]=new Array("To answer this question, you use the mass ratio from the balanced equation to determine the theoretical yield.<br>" ,"<br> The percent yield is determined as follows:<br>")
ansphrase[1]=new Array("To answer this question, you use the mass ratio from the balanced equation to determine the theoretical yield.<br>" ,"<br> Multiplying the theoretical yield by the percent (and dividing by 100), provides the actual yield.<br>")
function startit(){
	clear()
	totl++
	document.forms[0].total.value=totl
	document.forms[0].results.value=""
	//the choose() function is part of reactionsets.js. It picks a reaction and builds arrays of formulas and masses
	choose()
	buildquestion()
}
function buildquestion(){
	first=Math.floor(rxn[choice][0]*Math.random())
	second=first
	while(second<=(rxn[choice][0]-1))second=Math.floor(coeffs[choice].length*Math.random())
	moles=new Array()
	moles[0]=number(Math.random(),4,3)
	moles[1]=moles[0]*coeffs[choice][second]/coeffs[choice][first]
	moles[1]=number(moles[1],4,3)
//masses of the two compounds are gotten by calling the getmass function (part of reactionsets.js)
	given=new Array()
	given[0]=number(100*Math.random(),3,3)
	given[1]=number(given[0]*masses[second]/masses[first],3,3)
	percent=0
	while(percent<30 || percent>90)percent=100*Math.random();
	given[2]=percent*given[1]/100
	given[2]=number(given[2],3,3)
	percent=number(percent,3,3)
	option=Math.floor(2*Math.random())
	if(option==0){
	thequest=qphrase[0][0]+given[0]+qphrase[0][1]+formula[first]+qphrase[0][2]+given[2]+qphrase[0][3]+formula[second]+qphrase[0][4]+"<br>"+equation;
	theanswr=percent;
	}
	else{
	thequest=qphrase[1][0]+given[0]+qphrase[1][1]+formula[first]+qphrase[1][2]+percent+qphrase[1][3]+formula[second]+qphrase[1][4]+"<br>"+equation;
	theanswr=given[2];
	}
	buildanswer(option,masses,given,formula,percent)
	showquest(thequest)
}
function buildanswer(option,masses,given,formula,percent){
	eqn1="<B>theoretical yield of "+formula[second]+":</B>(mass of "+formula[second]+")/(mass of "+formula[first]+")*given mass<br>"+masses[second]+"/"+masses[first]+"*"+given[0]+"="+given[1] 
	if(option==0){
	eqn2="(actual/theory)*100=%yield<br>("+given[2]+"/"+given[1]+")*100="+percent+"%"
	}
	else{
	eqn2="(theory*%yield)/100=actual yield<br>("+given[1]+"*"+percent+")/100="+given[2]
	}
	theanswer=ansphrase[option][0]+eqn1+ansphrase[option][1]+eqn2
}	

function answer(ans){
	if(tried==1)alert("You've already done this one. Get a new Problem!");
	else{
	attempts++
	if(ans>.95*theanswr & ans<1.05*theanswr){
		tried=1
		document.forms[0].results.value="Correct"
		corrt++
		document.forms[0].correct.value=corrt
	}
	else{ if(tried==2){totl++;document.forms[0].total.value=totl};
		document.forms[0].results.value="Incorrect"
		tried=2
	}
}}
