function rnd(a,b) { return a + Math.floor(Math.random()*(b-a+1)); } function rndz(a,b) { var x; do { x=rnd(a,b); } while ( x==0); return x; } function hcf(a,b) { var c; while ( b!=0 ) { c = a%b; a=b; b=c; } return a; } function q1(){ var a = rnd(1,3); var b = a + rnd(1,3); var c = b + rnd(1,3); var d = c + rnd(1,3); var e = d + rnd(1,3); ans = (a+b+c+d+e)/5; qstr+="Find the mean of the numbers: " + a + ", " + b + ", " + c; qstr+=", " + d + ", " + e + "."; hint+="To calculate the mean, you need to add all the numbers together "; hint+="and then divide by the number of numbers."; } function q2(){ var a = rnd(1,3); var b = a + rnd(1,3); var c = b + rnd(1,3); var d = c + rnd(1,3); var e = d + rnd(1,3); var f = e + rnd(1,3); ans = (a+b+c+d+e+f)/6; ans=Math.round(ans*100)/100; qstr+="Find the mean of the numbers: " + a + ", " + b + ", " + c; qstr+=", " + d + ", " + e + ", " + f + "."; qstr+="
Give your answer correct to 2 decimal places."; hint+="To calculate the mean, you need to add all the numbers together "; hint+="and then divide by the number of numbers."; } function q3(){ var a = rnd(1,3); var b = a + rnd(1,3); var c = b + rnd(1,3); var d = c + rnd(1,3); var e = d + rnd(1,3); ans = c; qstr+="Find the median of the numbers: " + a + ", " + b + ", " + c; qstr+=", " + d + ", " + e + "."; hint+="To calculate the median, you need to find the middle number when the numbers "; hint+="are in increasing order."; } function q4(){ var a = rnd(1,3); var b = a + rnd(1,3); var c = b + rnd(1,3); var d = c + rnd(1,3); var e = d + rnd(1,3); var f = e + rnd(1,3); ans = (c+d)/2; qstr+="Find the median of the numbers: " + a + ", " + b + ", " + c; qstr+=", " + d + ", " + e + ", " + f + "."; hint+="To calculate the median, you need to find the middle number when the numbers "; hint+="are in increasing order. When there are an even number of numbers, you need to "; hint+="find the average of the two middle numbers."; } function q5() { var a = rnd(1,4); var b = 6-a; ans=b+"/6"; qstr+="If a single six-sided die is rolled once, what is the probability of getting "; qstr+="
a score greater than " + a + "?"; qstr+="
Give your answer as a fraction."; hint+="There are " + b + " ways a die can give a score greater than " + a + "."; } function q6(){ var a=rnd(2,12); if (a<8) b=a-1; else b=13-a; ans=b+"/36"; qstr+="If two six-sided dice are rolled together, find the probability "; qstr+="that the total score is " + a + "."; qstr+="
Give your answer as a fraction."; hint+="Draw a diagram (6x6) to represent the 36 possible outcomes,"; hint+="
then count those that give a total score of " + a + "."; } function q7(){ var a = rnd(8,12); var b = rnd(10,20); ans = a*b; qstr+="If the mean of " + a + " test scores is " + b + ", what is the total "; qstr+="of the " + a + " scores?"; hint+="Since MEAN = TOTAL / NUMBER, we have TOTAL = MEAN x NUMBER."; } function q8(){ var a = rnd(9,10); var b = rnd(10,20); var c = b + rnd(2,8); ans = (a*b+c)/(a+1); ans = Math.round(ans*100)/100; qstr+="After taking " + a + " tests, my mean score is " + b; qstr+="
In the next test my score is " + c + ". What is my new mean score?"; qstr+="
Give your answer correct to 2 decimal places."; hint+="First work out my total score after " + a + " tests,"; hint+="
then add my next score, and finally divide by " + eval(a+1); } function q9(){ var a=new Array(); for (var i=1; i<=7; i++ ) a[i]=rnd(3,20); var b=3; var c=20; for (i=1; i<=7; i++ ) { if (a[i]>b) b=a[i]; if (a[i]