How to Create Calculator in HTML

If you are looking for a calculator program written in HTML then you are in the right place. Here you will find the complete source code for the calculator with step by step implementation guide.

How to Create Calculator in HTML 

First of all, create the HTML structure for the calculator as follows:

<p style="background-color: white; border: 0px; color: #3a3a3a; font-family: &quot;Segoe UI&quot;, &quot;Helvetica Neue&quot;, Helvetica, sans-serif; font-size: 18px; margin: 0px 0px 1.5em; padding: 0px;">If you are looking for a calculator program written in HTML then you are in the right place. Here you will find the complete source code for the calculator with step by step implementation guide.</p><span data-inserter-version="2" face="&quot;Segoe UI&quot;, &quot;Helvetica Neue&quot;, Helvetica, sans-serif" id="ezoic-pub-ad-placeholder-118" style="background-color: white; border: 0px; color: #3a3a3a; font-size: 18px; margin: 0px; padding: 0px;"></span><span face="&quot;Segoe UI&quot;, &quot;Helvetica Neue&quot;, Helvetica, sans-serif" style="background-color: white; color: #3a3a3a; font-size: 18px;"></span><h2 style="background-color: white; border: 0px; color: #0a0101; font-family: &quot;Segoe UI&quot;, &quot;Helvetica Neue&quot;, Helvetica, sans-serif; font-size: 26px; font-weight: 400; line-height: 1.2em; margin: 0px 0px 20px; padding: 0px;"><u>How to Create Calculator in HTML&nbsp;</u></h2><p style="background-color: white; border: 0px; color: #3a3a3a; font-family: &quot;Segoe UI&quot;, &quot;Helvetica Neue&quot;, Helvetica, sans-serif; margin: 0px 0px 1.5em; padding: 0px;"><b><span style="font-size: large;">First of all, create the HTML structure for the calculator as follows:</span></b></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&lt;p style="background-color: white; border: 0px; color: #3a3a3a; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 18px; margin: 0px 0px 1.5em; padding: 0px;"&gt;If you are looking for a calculator program written in HTML then you are in the right place. Here you will find the complete source code for the calculator with step by step implementation guide.&lt;/p&gt;&lt;span data-inserter-version="2" id="ezoic-pub-ad-placeholder-118" style="background-color: white; border: 0px; color: #3a3a3a; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 18px; margin: 0px; padding: 0px;"&gt;&lt;/span&gt;&lt;span style="background-color: white; color: #3a3a3a; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 18px;"&gt;&lt;/span&gt;&lt;h2 style="background-color: white; border: 0px; color: #0a0101; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 26px; font-weight: 400; line-height: 1.2em; margin: 0px 0px 20px; padding: 0px;"&gt;How to Create Calculator in HTML&amp;nbsp;&lt;/h2&gt;&lt;p style="background-color: white; border: 0px; color: #3a3a3a; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 18px; margin: 0px 0px 1.5em; padding: 0px;"&gt;First of all, create the HTML structure for the calculator as follows:&lt;/p&gt;&lt;p style="background-color: white; border: 0px; color: #3a3a3a; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 18px; margin: 0px 0px 1.5em; padding: 0px;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;html&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp;&lt;head&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &lt;script&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//function that display value</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;function dis(val)</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;document.getElementById("result").value+=val</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//function that evaluates the digit and return result</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;function solve()</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;let x = document.getElementById("result").value</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;let y = eval(x)</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;document.getElementById("result").value = y</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//function that clear the display</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;function clr()</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;document.getElementById("result").value = ""</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &lt;/script&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &lt;!-- for styling --&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &lt;style&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.title{</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;margin-bottom: 10px;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;text-align:center;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;width: 210px;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;color:green;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;border: solid black 2px;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp;&nbsp;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input[type="button"]</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;background-color:white;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;color: black;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;border: solid black 2px;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;width:100%</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp;&nbsp;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input[type="text"]</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;background-color:white;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;border: solid black 2px;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;width:100%</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &lt;/style&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp;&lt;/head&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp;&lt;!-- create table --&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp;&lt;body&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &lt;div class="title"&gt;99learner Calculator&lt;/div&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &lt;table border="1"&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td colspan="3"&gt;&lt;input id="result" type="text" /&gt;&lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- clr() function will call clr to clear all value --&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="clr()" type="button" value="c" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- create button and assign value to each button --&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- dis("1") will call function dis to display value --&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('1')" type="button" value="1" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('2')" type="button" value="2" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('3')" type="button" value="3" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('/')" type="button" value="/" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('4')" type="button" value="4" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('5')" type="button" value="5" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('6')" type="button" value="6" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('-')" type="button" value="-" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('7')" type="button" value="7" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('8')" type="button" value="8" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('9')" type="button" value="9" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('+')" type="button" value="+" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('.')" type="button" value="." /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('0')" type="button" value="0" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- solve function call function solve to evaluate value --&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="solve()" type="button" value="=" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input onclick="dis('*')" type="button" value="*" /&gt; &lt;/td&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/tr&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp; &nbsp; &lt;/table&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&nbsp; &nbsp;&lt;/body&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;">&lt;/html&gt;</span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;"><br /></span></span></p><p style="border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="background-color: white; font-size: 18px;"><b><u>and your calculator is ready :</u></b></span></span></p><p style="background-color: white; border: 0px; margin: 0px 0px 1.5em; padding: 0px;"><span face="Segoe UI, Helvetica Neue, Helvetica, sans-serif" style="color: #3a3a3a;"><span style="font-size: 18px;"><br /></span></span></p><html>

   <head>

      <script>

         //function that display value

         function dis(val)

         {

             document.getElementById("result").value+=val

         }

           

         //function that evaluates the digit and return result

         function solve()

         {

             let x = document.getElementById("result").value

             let y = eval(x)

             document.getElementById("result").value = y

         }

           

         //function that clear the display

         function clr()

         {

             document.getElementById("result").value = ""

         }

      </script>

      <!-- for styling -->

      <style>

         .title{

         margin-bottom: 10px;

         text-align:center;

         width: 210px;

         color:green;

         border: solid black 2px;

         }

  

         input[type="button"]

         {

         background-color:white;

         color: black;

         border: solid black 2px;

         width:100%

         }

  

         input[type="text"]

         {

         background-color:white;

         border: solid black2px;

         width:100%

         }

      </style>

   </head>

   <!-- create table -->

   <body>

      <div class="title">99learner's Calculator</div>

      <table border="1">

         <tr>

            <td colspan="3"><input id="result" type="text" /></td>

            <!-- clr() function will call clr to clear all value -->

            <td><input onclick="clr()" type="button" value="c" /> </td>

         </tr>

         <tr>

            <!-- create button and assign value to each button -->

            <!-- dis("1") will call function dis to display value -->

            <td><input onclick="dis('1')" type="button" value="1" /> </td>

            <td><input onclick="dis('2')" type="button" value="2" /> </td>

            <td><input onclick="dis('3')" type="button" value="3" /> </td>

            <td><input onclick="dis('/')" type="button" value="/" /> </td>

         </tr>

         <tr>

            <td><input onclick="dis('4')" type="button" value="4" /> </td>

            <td><input onclick="dis('5')" type="button" value="5" /> </td>

            <td><input onclick="dis('6')" type="button" value="6" /> </td>

            <td><input onclick="dis('-')" type="button" value="-" /> </td>

         </tr>

         <tr>

            <td><input onclick="dis('7')" type="button" value="7" /> </td>

            <td><input onclick="dis('8')" type="button" value="8" /> </td>

            <td><input onclick="dis('9')" type="button" value="9" /> </td>

            <td><input onclick="dis('+')" type="button" value="+" /> </td>

         </tr>

         <tr>

            <td><input onclick="dis('.')" type="button" value="." /> </td>

            <td><input onclick="dis('0')" type="button" value="0" /> </td>

            <!-- solve function call function solve to evaluate value -->

            <td><input onclick="solve()" type="button" value="=" /> </td>

            <td><input onclick="dis('*')" type="button" value="*" /> </td>

         </tr>

      </table>

   </body>

</html>


and your calculator is ready :


99learner's Calculator

No comments:

Post a Comment

we are here to give you motivational quotes , fun facts and other articles....
If you have any doubts, pls let me know.

Celebrities Banned In Other Countries

 Banned Celebrity By Countries 1. Justin Bieber (Singer and Popstar) Banned in- Argentina and China Due to- (1) Disrespect Argentina flag by...