I am struggling to create an HTML code for performing basic mathematical operations like addition, subtraction, division, and multiplication with multiple numbers. I have tried adding some CSS for styling purposes, but my main concern is getting the code to work correctly. I am using JavaScript as well. Can someone please help me figure out what I'm doing wrong?
<html>
<head>
<body bgcolor="FFFCC">
<table border="0" cellpadding="0"
cellspacing="1" style="border-collapse: collapse"
bordercolor="#1111" width="50%">
<hi><p align="center">CALCULATOR</p></hi><br>
<script language="javascript">
function ADD()
{
var first = parseFloat(txtNumber1.value);
var second = parseFloat(txtNumber2.value);
var Ans = first + second;
txtAnswer.value = Ans;
}
function MINUS()
{
var first = parseFloat(txtNumber1.value);
var second = parseFloat(txtNumber2.value);
var Ans = first - second;
txtAnswer.value = Ans;
function DIVIDE()
{
var first = parseFloat(txtNumber1.value);
var second = parseFloat(txtNumber2.value);
var Ans = first / second;
txtAnswer.value = Ans;
}
function MULTIPLY()
{
var first = parseFloat(txtNumber1.value);
var second = parseFloat(txtNumber2.value);
var Ans = first * second;
txtAnswer.value = Ans;
}
function MODULO()
{
var first = parseFloat(txtNumber1.value);
var second = parseFloat(txtNumber2.value);
var Ans = first % second;
txtAnswer.value = Ans;
}
</script>
</head>
<input type="text" name="txtNumber1"/><br>
<input type="text" name="txtNumber2"/><br>
<input type="button" name="butAnswer"
value="+" onclick="ADD()"/>
<input type="button" name="butAnswer"
value="-" onclick="MINUS()"/>
<input type="button" name="butAnswer"
value="/" onclick="DIVIDE()"/>
<input type="button" name="butAnswer"
value="*" onclick="MULTIPLY()"/>
<input type="button" name="butAnswer"
value="%" onclick="MODULO()"/><br>
<input type="text" name="txtAnswer"/>
</table>
</body>
</html>