I have a problem building a simple prompt message that will ask the user the ff.
First no.
Second No.
Operator being used + - * / %
So far, i have this codes:
Kindly help me.. Thaaanks!
<html>
<body>
<script type="text/javascript">
var num1, num2, ope, sum, diff, prod, quo, mod;
num1=Number(prompt("Enter First number: "));
num2=Number(prompt("Enter Second number: "));
ope=Operators(prompt("Choose Operator : + - * / %"));
if (ope==+)
{
sum=num1+num2;
document.write("The sum is: "+sum);
}
else if (ope==-)
{
diff=num1-num2;
document.write("The difference is: "+diff);
}
else if (ope==*)
{
prod=num1*num2;
document.write("The product is: "+prod);
}
else if (ope==/)
{
quo=num1/num2;
document.write("The quotient is: "+quo);
}
else if (ope==%)
{
mod=num1%num2;
document.write("The remainder is: "+mod);
}
else
{
document.write("INVALID!");
}
document.write("First Number: "+num1);
document.write("<br>");
document.write("Second Number: "+num2);
document.write("<br>");
document.write("Operator Used: "+operator);
</script>
</body>
</html>