CALCULATOR USING SWITCH
************************************************************************
W.A.P TO MAKE A CALCULATOR USING SWITCH CASE
************************************************************************
JAVA Program
Output:
************************************************************************
C Program
Online Compiler
************************************************************************
C++ Program
Online Compiler
************************************************************************
C# Program
************************************************************************
PHP Program
Php is a server side scripting language.
************************************************************************
JAVASCRIPT Program
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title>
<script type="text/javascript">
function check() {
var n1= document.getElementById('n1').value;
var n2= document.getElementById('n2').value;
var op= document.getElementById('cal').value;
var cc;
switch(op)
{
case "+":
cc= parseFloat(n1)+ parseFloat(n2);
break;
case "-":
cc= parseFloat(n1) -parseFloat(n2);
break;
case "*":
cc= parseFloat(n1)* parseFloat(n2);
break;
case "/":
cc= parseFloat(n1) /parseFloat(n2);
break;
default:
break;
}
document.getElementById('ans').innerText= cc;
}
</script>
</head><body>
<input type="number" name="" id="n1"/>
<select id="cal">
<option value="+" id="p">+</option>
<option value="-" id="mi">-</option>
<option value="*" id="mu">*</option>
<option value="/" id="d">/</option>
</select>
<input type="number" name="" id="n2"/>
<br>
<button onclick="check()">CALCULATE</button>
<h2 id="ans" ></h2>
</body></html>
************************************************************************
PYTHON Program
************************************************************************
Comments
Post a Comment