Page

Adding and multiply two numbers using java script

<html>
<title>script</title>
<body>
<body bgcolor="RED">
<script language="javascript">

var x=prompt("Enter the First number ");
var a=parseInt(x);
var y=prompt("Enter the Second number ");
var b=parseInt(y);
var z=prompt("Enter the choice ");
var d=parseInt(z);


if (z==1)
{
document.write("<br>The First Number is : " +x );
document.write("<br>The Second Number is : " +y );
var c=a+b;
document.write("<br>The Result Is : " +c );
}
else if(z==2)
{
document.write("<br>The First Number is : " +x );
document.write("<br>The Second Number is : " +y );
var c=a*b;
document.write("<br>The Result Is : " +c );
}
else
{
document.write("<br>wrong choice " );
}
</script>
</body>
</html>
<!-- NOTE : Choice 1 for adding and Choice 2 for multiply-->

No comments:

Post a Comment