var answerN = 0;
var answerD = 0;
var answerR = 0;
var c1 = 0;
var n1 = 0;
var n2 = 0;
var outputc1 = "";
outputn1 = "";
var opSign = "";
var gtorlt = "";
function showProblem() {
var ran1 = Math.random() * (20) - 10;
var ran2 = Math.random() * (20) - 10;
var ran3 = Math.random() * (20) - 10;
c1 = Math.ceil(ran1);
n1 = Math.ceil(ran2);
n2 = Math.ceil(ran3);
outputc1 = c1;
if (c1 == -1) {outputc1 = "-"};
if (c1 == 1) {outputc1 = ""};
if (c1 == 0) {showProblem()};
if (n1 == 0) {showProblem()};
outputn1 = n1;
if (n1 < 0) {
opSign = "x - ";
outputn1 = -1*n1;
}
else {opSign = "x + "};
document.theForm.output1.value = outputc1 + opSign + outputn1 + " > " + n2;
document.theForm.output2.value = "";
document.theForm.output3.value = "";
document.theForm.output4.value = "";
}
function showStep2(){
answerN = n2 - n1;
document.theForm.output4.value = outputc1 + "x > " + answerN;
}
function doProblem(){
answerN = n2 - n1;
answerD = c1;
for (var f = 10; f > 0; f --) {
if (Math.ceil(answerN/f) == Math.floor(answerN/f) &&
Math.ceil(answerD/f) == Math.floor(answerD/f)) {
answerN = answerN/f;
answerD = answerD/f;
}
}
if (answerD < 0){
answerD *= -1;
answerN *= -1;
}
if (c1 < 0) { gtorlt = "x < "}
else {gtorlt = "x > "};
if (answerN == 0) {
document.theForm.output2.value = gtorlt + "0"
document.theForm.output3.value = gtorlt + "0"
}
else
if (answerD == 1) {
document.theForm.output2.value = gtorlt + answerN
document.theForm.output3.value = gtorlt + answerN
}
else {
document.theForm.output2.value = gtorlt + answerN + "/" + answerD
document.theForm.output3.value = gtorlt + Math.round(answerN * 1000 / answerD) / 1000
}
}
//STOP HIDING -->