0% found this document useful (0 votes)
38 views

Objective: S/W Requirement H/W Requirement

The document contains programs written in HTML and JavaScript to: 1) Add two numbers by inputting values and clicking a button to display the result. 2) Perform arithmetic operations (addition, subtraction, multiplication, division) on two numbers in a similar manner. 3) Design a basic calculator interface with number and operator buttons to enter and evaluate expressions.

Uploaded by

sheeldhaliwal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Objective: S/W Requirement H/W Requirement

The document contains programs written in HTML and JavaScript to: 1) Add two numbers by inputting values and clicking a button to display the result. 2) Perform arithmetic operations (addition, subtraction, multiplication, division) on two numbers in a similar manner. 3) Design a basic calculator interface with number and operator buttons to enter and evaluate expressions.

Uploaded by

sheeldhaliwal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

DISHA MOR 81005113017

--------------------------------------------------------------------------------------------------------------------------------

10. Write a program in HTML to add two numbers.

---------------------------------------------------------------------------------------------------------------------

Objective: To write a program in HTML to add two numbers.

S/W Requirement: Web Browser (Internet Explorer, Mozilla), Notepad

H/W Requirement: Intel P-IV, 256 MB Ram.


Program:

<html>

<head>

<title>Add</title>

<script language="javascript">

function add(){

var a=parseInt(document.f1.t1.value);

var b=parseInt(document.f1.t2.value);

document.f1.r.value=eval(a+b);

</script>

</head>

<body bgcolor=orange>

<form name="f1">

<input type="text" name="t1">

<input type="text" name="t2">

<input type="button" value="Result" onclick="add();">

input type="text" name="r">

</form>

</body>

</html>

DEPARTMENT OF INFORMATION TECHNOLOGY


DISHA MOR 81005113017

Output:

Conclusion: We understand that how to add two numbers in HTML.

DEPARTMENT OF INFORMATION TECHNOLOGY


DISHA MOR 81005113017

------------------------------------------------------------------------------------------------------------------------------------------

11. Write a program in HTML to perform addition, subtraction, multiplication and division on two
numbers.

-------------------------------------------------------------------------------------------------------------------------------

Objective: To write a program in HTML to perform addition, subtraction, multiplication and division on
two numbers.

S/W Requirement: Web Browser (Internet Explorer, Mozilla), Notepad

H/W Requirement: Intel P-IV, 256 MB Ram.


Program:

<html>

<head>

<title>Arithmetic Operations</title>

<Script Language ="JavaScript">

function add()

var x=parseInt(document.o.t1.value);

var y=parseInt(document.o.t2.value);

var z=x+y;

document.o.t3.value=z;

function sub()

var x=parseInt(document.o.t4.value);

var y=parseInt(document.o.t5.value);

var z=x-y;

document.o.t6.value=z;

function mul()

DEPARTMENT OF INFORMATION TECHNOLOGY


DISHA MOR 81005113017

var x=parseInt(document.o.t7.value);

var y=parseInt(document.o.t8.value);

var z=x*y;

document.o.t9.value=z;

function div()

var x=parseInt(document.o.t10.value);

var y=parseInt(document.o.t11.value);

var z=x/y;

document.o.t12.value=z;

</Script>

</head>

<body bgcolor=violet>

<form name="o">

<input type="text" name="t1">

<input type="button" onclick="add()" value="+"></button>

<input type="text" name="t2"><input type="button" onclick="add()" value="="></button>

<input type="text" name="t3">

<br>

<input type="text" name="t4"> &nbsp<input type="button" onclick="sub()"


value="-"></button>

<input type="text" name="t5"><input type="button" onclick="sub()" value="="></button>

<input type="text" name="t6">

<br>

<input type="text" name="t7"> &nbsp<input type="button" onclick="mul()"


value="*"></button>

DEPARTMENT OF INFORMATION TECHNOLOGY


DISHA MOR 81005113017

<input type="text" name="t8"><input type="button" onclick="mul()" value="="></button>

<input type="text" name="t9">

<br>

<input type="text" name="t10"> &nbsp<input type="button" onclick="div()"


value="/"></button>

<input type="text" name="t11"><input type="button" onclick="div()" value="="></button>

<input type="text" name="t12">

<br>

</form>

</body>

</html>

Output:

Conclusion: We understand that how to perform addition, subtraction, multiplication and division on two
numbers in HTML.

DEPARTMENT OF INFORMATION TECHNOLOGY


DISHA MOR 81005113017

------------------------------------------------------------------------------------------------------------------------------------------

12. Write a program in HTML design a calculator and perform operations using it.

-------------------------------------------------------------------------------------------------------------------------------

Objective: To write a program in HTML to design a calculator and perform operations using it.

S/W Requirement: Web Browser (Internet Explorer, Mozilla), Notepad

H/W Requirement: Intel P-IV, 256 MB Ram.


Program:

<html>

<head>

<title>Calculator</title>

</head>

<body>

<center>

<form name="Cal">

<table border=4>

<tr>

<td>

<input type="text" name="Input" size="16"><br>

</td>

</tr>

<tr>

<td>

<input type="button" name="one" value=" 1 " OnClick="Cal.Input.value += '1'">

<input type="button" name="two" value=" 2 " OnClick="Cal.Input.value += '2'">

<input type="button" name="three" value=" 3 " OnClick="Cal.Input.value += '3'">

<input type="button" name="sum" value=" + " OnClick="Cal.Input.value += ' + '"><br>

<input type="button" name="four" value=" 4 " OnClick="Cal.Input.value += '4'">

<input type="button" name="five" value=" 5 " OnClick="Cal.Input.value += '5'">

DEPARTMENT OF INFORMATION TECHNOLOGY


DISHA MOR 81005113017

<input type="button" name="six" value=" 6 " OnClick="Cal.Input.value += '6'">

<input type="button" name="sub" value=" - " OnClick="Cal.Input.value += ' - '"><br>

<input type="button" name="seven" value=" 7 " OnClick="Cal.Input.value += '7'">

<input type="button" name="eight" value=" 8 " OnClick="Cal.Input.value += '8'">

<input type="button" name="nine" value=" 9 " OnClick="Cal.Input.value += '9'">

<input type="button" name="mul" VALUE=" x " OnClick="Cal.Input.value += ' * '"><br>

<input type="button" name="clear" value=" c " OnClick="Cal.Input.value = ''">

<input type="button" name="zero" value=" 0 " OnClick="Cal.Input.value += '0'">

<input type="button" name="action" value=" = " OnClick="Cal.Input.value =


eval(Calc.Input.value)">

<input type="button" name="divide" value=" / " OnClick="Cal.Input.value += ' / '"><br>

</td>

</tr>

</table>

</form>

</center>

</body>

</html>

Output:

Conclusion: We understand that how to design a calculator in HTML and perform operations using it.

DEPARTMENT OF INFORMATION TECHNOLOGY


DISHA MOR 81005113017

DEPARTMENT OF INFORMATION TECHNOLOGY

You might also like