Post Lab
Post Lab
Practical No. 09
(POST-LAB)
Aim: Design & develop Simple Calculator in HTML using eval() in JavaScript and CSS
Semester/Year: ______________
Aim: Design & develop a Simple Calculator in HTML using eval() in JavaScript and CSS
Hardware Requirement:
Software Requirement:
Firebase Database.
THEORY:
JavaScript:
JavaScript is a high-level, versatile programming language that is primarily known for its use in web
development to make web pages interactive. It is an interpreted language, meaning that it is executed by a
web browser without the need for compilation. JavaScript is a key component of web development
alongside HTML and CSS.
JavaScript is an object-oriented language, which means it uses objects to organize and structure
code. Objects in JavaScript can encapsulate properties and methods, making it a versatile
language for creating modular and reusable code.
JavaScript has several data types, including numbers, strings, booleans, objects, arrays, and more.
Variables are used to store and manipulate data, and they are dynamically typed, meaning that a
variable can hold different types of data at different times.
• Functions:
Functions are blocks of reusable code that perform a specific task. JavaScript functions can be
defined using the function keyword and can take parameters, return values, and be assigned to
variables.
• Control Flow:
Department of Computer Science & Engineering, S.B.J.I.T.M.R, Nagpur
System Lab (PCCCS305P)
JavaScript supports various control flow statements, including if, else, switch, for, while, and do-
while. These statements allow developers to control the execution flow of their code based on
conditions and loops.
• Event Handling:
JavaScript is widely used for handling events in the browser, such as user interactions (clicks,
keypresses, etc.) and changes in the document structure (loading, resizing, etc.). Event handling is
essential for creating interactive and responsive web pages.
Firebase:
Firebase is a NoSQL cloud database which store its data as JSON objects. A NoSQL database provides a
mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used
in relational databases. Also Firebase is a backend platform for building Web, Android and IOS
applications. It offers real time database, different APIs, multiple authentication types and hosting
platform. This is an introductory tutorial, which covers the basics of the Firebase platform and explains
how to deal with its various components and sub-components.
Firebase Features:
• Real-time Database − Firebase supports JSON data and all users connected to it receive live updates
after every change.
• Authentication − We can use anonymous, password or different social authentications.
• Hosting − The applications can be deployed over secured connection to Firebase servers.
Firebase Advantages:
CODE:
HTML Code:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calci</title>
<script type = text/javascript></script>
<style></style>
</head>
<body>
<center>
<h1>Simple Calculator</h1>
<table>
<tr><input id = "display"></tr>
<tr><td> <button onclick = fun(0)>0</button></td>
<td> <button onclick = fun("(")>(</button></td>
<td> <button onclick = fun(")")>)</button></td>
<td></td>
<td> <button onclick = C()>C</button></td>
<td> <button onclick = B()>B</button></td>
</tr>
<tr><td> <button onclick = fun(7)>7</button></td>
<td> <button onclick = fun(8)>8</button></td>
<td> <button onclick = fun(9)>9</button></td>
<td></td>
<td> <button onclick = fun("+")>+</button></td>
<td> <button onclick = fun("-")>-</button></td>
</tr>
<tr><td> <button onclick = fun(6)>6</button></td>
<td> <button onclick = fun(5)>5</button></td>
<td> <button onclick = fun(4)>4</button></td>
<td></td>
<td><button onclick = fun("*")>*</button></td>
<td><button onclick = fun("/")>/</button></td>
</tr>
<tr><td> <button onclick = fun(1)>1</button></td>
<td> <button onclick = fun(2)>2</button></td>
Department of Computer Science & Engineering, S.B.J.I.T.M.R, Nagpur
System Lab (PCCCS305P)
Java Script:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calci</title>
<script type = text/javascript>
function fun(a)
{
document.getElementById("display").value+=a;
}
function C()
{
document.getElementById("display").value = "";
}
function B()
{
var y = document.getElementById("display").value;
document.getElementById("display").value = y.slice(0, y.length-1);
}
function res()
{
var a = document.getElementById("display").value;
document.getElementById("display").value=a+"="+eval(a);
}
</script>
Department of Computer Science & Engineering, S.B.J.I.T.M.R, Nagpur
System Lab (PCCCS305P)
OUTPUT:
CONCLUSION:
REFERENCE:
www.tutorialspoint.com/plsql
https://www.tutorialandexample.com/firebase-interview-questions/
https://w3schools.com /