<html>
<body>
<script>
var a=prompt(“Enter a number”);
var c=prompt(“Enter operator”);
var b=prompt(“Enter another number”);

var sum;
switch(c)
{
case ‘+’:sum=a+b
break;
case ‘-‘:sum=a-b
break;
case ‘*’:sum=a*b
break;
case ‘/’:sum=a/b
break;
default: sum=”undefined”;
}
document.write(“Answer is equal to: “,sum);
</script>
</body>
</html>

Leave a Reply