PROGRAM IN JAVASCRIPT FOR CALCULATOR(MODEL-1)

 <html>

<head>

<script type = "text/javascript">

function calculator(){

var f=parseInt(window.document.calc.a.value);

var s=parseInt(window.document.calc.b.value);

var op=window.document.calc.c.value;

if (op=="+"){

        document.writeln("ADDITION OF TWO NUMBERS="+(f+s));

}

if (op=="-"){

        document.writeln("subtraction OF TWO NUMBERS="+(f-s));

}

if (op=="*"){

        document.writeln("product OF TWO NUMBERS="+(f*s));

}

if (op=="/"){

        document.writeln("Division OF TWO NUMBERS="+(f/s));

}

}

</script>

</head>

<body>

<form name="calc">

ENTER FIRST NUMBER:<Input type="text" name="a"><br>

ENTER SECOND  NUMBER:<Input type="text" name="b"><br>

ENTER the operation to perform:<Input type="text" name="c"><br>

<Input type="button" onclick="calculator();return false;" value="CLICK ME"><br>

</form>

</body>

</html>

No comments:

Post a Comment