0% found this document useful (0 votes)
45 views2 pages

Experiment 3 AKASH WT&AS

The document describes creating a simple JavaScript calculator that performs basic math operations like sum, product, difference, and quotient on two user-inputted numbers. It includes the HTML, CSS, and JavaScript code to build an interface with inputs for the two numbers and buttons to calculate and output the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

Experiment 3 AKASH WT&AS

The document describes creating a simple JavaScript calculator that performs basic math operations like sum, product, difference, and quotient on two user-inputted numbers. It includes the HTML, CSS, and JavaScript code to build an interface with inputs for the two numbers and buttons to calculate and output the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment – 3

3-
Write a Javascript to design a simple calculator to perform the following operations:
Sum, Product, Difference and Quotient.

CODE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Calculator using html, css, bootstrap and javascript</title>
<script type="text/javascript">
function SubmitClick(){
var a = parseInt(document.getElementById("num1").value);
var b = parseInt(document.getElementById("num2").value);
var sum = a + b;
var product= a * b;
var diff = a - b;
var quotient = a / b;
document.getElementById("sum").value = sum;
document.getElementById("product").value = product;
document.getElementById("diff").value = diff;
document.getElementById("quotient").value = quotient;
}
</script>
</head>
<body style="background-color:lightblue;">
<div class="container">
<h2> Simple Calculator </h2>
<form method="get" onsubmit="event.preventDefault(); SubmitClick();">
Enter first number: &nbsp;<br>
<input type="number" id="num1" name="num1"> <br>
Enter Second number: &nbsp;<br>
<input type="number" id="num2" name="num2"> <br>
The Sum of two numbers is: &nbsp;<br>
<input type="number" id="sum" name="sum"> <br>
The Product of two numbers is: &nbsp;<br>
<input type="number" id="product" name="product"> <br>
The difference of two numbers is: &nbsp;<br>
<input type="number" id="diff" name="diff"> <br>
The quotient of two numbers is: &nbsp;<br>
<input type="number" id="quotient" name="quotient"> <br>
<button type="submit"> Calculate </button>
</form>
</div>
</body>
</html>

OUTPUT

Submitted By:-
Swapneswar Mishra
2101020552
CSI21032
Group- 08

You might also like