function love1_check() { if(document.forms[0].elements[0].value == "1:8") { alert("Correct"); } else { alert("Incorrect"); } } function probability_check() { if( document.forms[0].elements[0].value =="1:7" || document.forms[0].elements[0].value == "1/7" ) { alert("Correct"); } else { alert("Incorrect"); } return false; } function probability2_check1() { var str = document.forms[0].elements[0].value; if( str.length > 0 && str.indexOf(":") == -1 ) { alert("Remember, you must put your answer in its simplest form separated by a colon."); } else { if(str == "1:3") { alert("Correct!"); } else { alert("Incorrect."); } } return false; } function probability2_check2() { var str = document.forms[1].elements[0].value; if( str.length > 0 && str.indexOf(":") == -1 ) { alert("Remember, you must put your answer in its simplest form separated by a colon."); } else { if( str == "1:4") { alert("Correct!"); } else { alert("Incorrect."); } } return false; } function combinations_check() { if(document.forms[0].elements[0].value == "12") { alert("Correct!"); } else { alert("Incorrect. Try Again."); } return false; } function slappy_check() { if(document.forms[0].elements[0].value == "36") { alert("Correct!"); } else { alert("Incorrect. Try Again."); } return false; } function chips_GrabChip() { var str=GrabFromBag(); if(document.forms[0].elements[0].value.indexOf(str) != -1) { repeats++; document.forms[0].elements[0].value = str + ", " + (repeats+1); } else { repeats = 0; document.forms[0].elements[0].value = str; } } function chips_check() { if(document.forms[0].elements[2].value == "1") { alert("Correct!"); } else { alert("Incorrect. Make sure you do enough trials!"); } return false; } function prob4_check() { if(document.forms[0].elements[0].value == "6") { if( confirm("Correct. Would you like to try another problem?") ) { self.parent.top.location = "lotteryex2.html"; } } else { alert("Incorrect."); } return false; } function lotteryex2_check1() { var str = document.forms[0].elements[0].value; if(str.length > 0 && str.indexOf(":") == -1) { alert("Express your answers as a ratio in simplest form using a colon to separate the numbers, such as 3:4."); } else { if( str == "1:1000000" || str == "1:1,000,000") { alert("Correct!"); } else { alert("Incorrect."); } } return false; } function lotteryex2_check2() { if(document.forms[1].elements[0].value == "5") { alert("Correct!"); } else { alert("Incorrect."); } return false; } function lotteryex2_check3() { var str = document.forms[2].elements[0].value; if(str.length > 0 && str.indexOf(":") == -1) { alert("Express your answers as a ratio in simplest form using a colon to separate the numbers, such as 3:4."); } else { if( str == "1:4" ) { alert("Correct!"); } else { alert("Incorrect."); } } return false; } //global marlowe variables: var marlowe1_errorMsg=""; var marlowe2_errorMsg=""; var marlowe3_errorMsg=""; function marlowe1_probability() { //should be implemented as a pop-up window rather than a dialog. alert("Probability is the number of favorable outcomes over the number of possible outcomes. The probability of rolling a 'five' on a six sided die is 1:6 because there are six possible outcomes (sides with 1 to 6 dots) and one favorable outcome (the side with 5 dots)."); } function marlowe1_BigCheck() { if( marlowe1_check1() && marlowe1_check2() && marlowe1_check3 && marlowe1_check4() ) { self.parent.top.location = "marlowe2.html"; } else { alert( marlowe1_errorMsg ); } marlowe1_errorMsg = ""; } function marlowe1_check1() { var str = document.forms[0].elements[0].value; if( str.length > 0 && str.indexOf(":") == -1 ) { marlowe1_errorMsg += "Express probability as a ratio in simplified form. "; return false; } else { if( str == "1:6" ) { return true; } else { marlowe1_errorMsg += "The probability in #1 isn't quite right. "; return false; } } } function marlowe1_check2() { var str = document.forms[0].elements[1].value; if(str == "no" || str =="No" || str == "n" || str == "N" || str.indexOf("no") != -1 || str.indexOf("No") != -1 ) { return true; } else { marlowe1_errorMsg += "Are you SURE Marlowe has a good chance of getting a guard who falls completely asleep? "; return false; } } function marlowe1_check3() { var str = document.forms[0].elements[2].value; if( str.length > 0 && str.indexOf(":") == -1 && str.indexOf("Express probability as a ratio in simplified form. ") == -1 ) { marlowe1_errorMsg += "Express probability as a ratio in simplified form. "; return false; } else { if( str == "1:2" ) { return true; } else { marlowe1_errorMsg += "I'm not sure Marlowe has a " + str + " probability of getting a heavy or light sleeper. "; return false; } } } function marlowe1_check4() { var str = document.forms[0].elements[1].value; if(str == "no" || str =="No" || str == "n" || str == "N" || str.indexOf("no") != -1 || str.indexOf("No") != -1 ) { return true; } else { marlowe1_errorMsg += "So what if Marlowe waits around? Nobody said anything about the guards sleeping deeper as the night goes on. "; return false; } } function marlowe2_BigCheck() { var allCorrect=true; if( !marlowe2_check1() ) { allCorrect=false; } if( !marlowe2_check2() ) { allCorrect=false; } if( !marlowe2_check3() ) { allCorrect=false; } if(!marlowe2_check4() ) { allCorrect=false; } if(allCorrect) { self.parent.top.location="marlowe2b.html"; } else { alert(marlowe2_errorMsg); } marlowe2_errorMsg=""; } function marlowe2_check1() { if(eval(document.forms[0].elements[0].value) == 372) { return true; } else { marlowe2_errorMsg = "The first answer is not quite right."; return false; } } function marlowe2_check2() { var str = document.forms[0].elements[1].value; if(str == "") { marlowe2_errorMsg += " You must answer the second question. "; return false; } if( str.indexOf(":") == -1 && str.indexOf("Express probability as a ratio in simplified form. ") == -1 ) { marlowe2_errorMsg += " Express probability as a ratio in simplified form. "; return false; } else { if( str == "1:372" ) { return true; } else { marlowe2_errorMsg += " Are you sure that Marlowe has a " + str + " probability that she will guess the correct numbers? "; return false; } } } function marlowe2_check3() { var str = document.forms[0].elements[2].value; if(str == "") { str ="that"; } if( str == "1:45" ) { return true; } else { marlowe2_errorMsg+=" Nope, " + str + " is not correct for #3. " return false; } } function marlowe2_check4() { var str = document.forms[0].elements[3].value; if( str.length > 0 && str.indexOf(":") == -1 && marlowe2_errorMsg.indexOf("Express probability as a ratio in simplified form. ") != -1 ) { marlowe2_errorMsg += "Express probability as a ratio in simplified form. "; return false; } else { if( str == "1:6" ) { return true; } else { marlowe2_errorMsg += " The ratio in the last question doesn't represent the correct probability. "; return false; } } } function marlowe3_BigCheck() { if( marlowe3_check1() && marlowe3_check2() ) { self.parent.top.location = "marlowe4.html"; } else { if( marlowe3_errorMsg.indexOf("is not") != -1 ) { alert( marlowe3_errorMsg); } else { alert(marlowe3_errorMsg); } } marlowe3_errorMsg =""; } function marlowe3_check1() { var str = document.forms[0].elements[0].value; if( str.indexOf("%") == -1 ) { marlowe3_errorMsg = "You must express your answer as a percent. "; return false; } else { if( str == "37.5%" ) { return true; } else { marlowe3_errorMsg = str + " is not the correct experimental probability of Marlowe making it over the wall."; return false; } } } function marlowe3_check2() { var str = document.forms[0].elements[1].value; if( str.indexOf("%") == -1 && marlowe3_errorMsg.indexOf("You must express your answer as a percent.") == -1) { marlowe3_errorMsg += "You must express your answer as a percent. "; return false; } else { if( str == "50%" ) { return true; } else { marlowe3_errorMsg += str + " is not the correct theoretical probability of Marlowe making it over the wall."; return false; } } } function marlowe4_BigCheck() { var errorMsg=""; var correct=true; var tempStr=document.forms[0].elements[2].value; if(document.forms[0].elements[0].value != "50") { errorMsg += "Are you sure that's the surface area of the stones?"; correct = false; } if(tempStr != "21") { if(tempStr.length < 1) { tempStr = "That"; } errorMsg += " "+ tempStr + " is not the correct surface area of the bridge."; correct = false; } if( correct && document.forms[0].elements[1].checked != true ) { errorMsg = "You have the correct surface areas, but you need to select the one with the most surface area."; alert(errorMsg); } else { if(correct) { self.parent.top.location = "marlowe5.html"; } else { alert(errorMsg); } } return false; } /******************************************************************** "Machine's" Code; no pages access the following functions directly. *********************************************************************/ //global variable for the bag of chips machine var repeats=0; function Die(range) { var tempVal; do { tempVal=Math.random()*10; tempVal=parseInt(tempVal); } while(!CheckVal(tempVal, range)); return tempVal; } function CheckVal(num, range) { var check=false; for(var i=0; i<=range; i++) { if(num == i) { check=true; } } return check; } function GrabFromBag() { var num=Die(10); if(num > 0 && num <= 3) { return "red"; } else { if(num > 3 && num <= 5) { return "blue"; } else { if(num > 5 && num <= 6) { return "yellow"; } else { return "green"; } } } }