Thursday, December 19, 2019

Calculator in JavaScript Programming Language

A simple calculator was written by my close friend and fellow software engineer Sir  Ernel Fadriquilan using JavaScript programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/
https://www.unlimitedbooksph.com/

If you like my video tutorials kindly click the like button and subscribe for more video tutorials on my channel.

Thank you very much for your help and support.



Sample Program Output



Program Listing

index.html

<html>
<head>
<style>
.ct {
height: 160px;
width: 270px;
background-color: orange;
border: 6px solid white;
padding: 30px;
margin-top: 50px;
}
#fm {
color: yellow;
font-family: arial;
font-size: 150%;
font-weight: bolder;
}
#ip {
color: red;
background-color: white;
font-family: arial;
font-size: 100%;
font-weight: bolder;
border: 6px solid white;
}
p {
color: blue;
font-family: arial;
font-size: 150%;
font-weight: bolder;
text-align: center;
}
</style>
</head>
<body>
<script>
function check () {
if (form.a.value == " " || form.b.value == " " ) {
alert ("data is empty");
exit;
}
}
function add () {
check ();
a=eval (form.a.value);
b=eval (form.b.value);
c=a+b
form.total.value = c;
}
function time () {
check ();
a=eval (form.a.value);
b=eval (form.b.value);
c=a*b
form.total.value = c;
}
function subtract () {
check ();
a=eval (form.a.value);
b=eval (form.b.value);
c=a-b
form.total.value = c;
}
function divide () {
check ();
a=eval (form.a.value);
b=eval (form.b.value);
c=a/b
form.total.value = c;
}
function reset () {
form.a.value=" ";
form.b.value=" ";
form.total.value = " ";
}
</script>
<center>
<div class="ct">
<form id="fm" name="form">
1st <input id="ip" type="text" name="a" size="3">
2nd <input id="ip" type="text" name="b" size="3"><br><br>
= <input id="ip" type="text" value=" " name="total" size="9"><br><br>
<input id="ip" type="button" name="submit" onclick="add ()" value="+">
<input id="ip" type="button" name="submit" onclick="time ()" value="×">
<input id="ip" type="button" name="submit" onclick="divide ()" value="/">
<input id="ip" type="button" name="submit" onclick="subtract ()" value="-">
<input id="ip" type="button" name="submit" onclick="reset ()" value="Clear">
</form>
</div>
</center>
<p>MDAS</p>
</body>
</html>




No comments:

Post a Comment