GithubHelp home page GithubHelp logo

calc's Introduction

Ex.08 Design of a Standard Calculator

Date:20.12.2023

AIM:

To design a web application for a standard calculator with minimum five operations.

DESIGN STEPS:

Step 1:

Clone the github repository and create Django admin interface.

Step 2:

Change settings.py file to allow request from all hosts.

Step 3:

Use CSS for creating attractive colors.

Step 4:

Write JavaScript program for implementing five different operations.

Step 5:

Validate the HTML and CSS code.

Step 6:

Publish the website in the given URL.

PROGRAM :

<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Calculator</title>
   <script>
      function display(val) {
         document.getElementById('result').value += val;
      }
      function SolveCalculation() {
         var x = document.getElementById('result').value;
         var y = eval(x);
         document.getElementById('result').value = y;

      }
      function ClearFuntion() {
         document.getElementById('result').value = ''
      }
      function deleteFuntion() {
         var temp = ''
         temp = document.getElementById('result').value;
         var len = temp.length;
         temp = temp.substring(0, len - 1)
         document.getElementById('result').value = temp;
      }
      function squareRoot(){
         var x = document.getElementById('result').value ;
         var result = Math.pow(x,0.5)
         document.getElementById('result').value=result
      }

   </script>
   <style>
      .App-container {
         padding: 100px;
         margin-top: 5%;
         line-height: 55px;
         border: none;
         border-radius: 5px;
         box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.6), 0 6px 20px 0 rgba(0, 0, 0, 0.39);
         margin-left: 25%;
         margin-right: 25%;
         text-align: center;
         background-color: pink;
      }
      #h1{
         text-align: center;
      }
      #numberButton,
      #operatorButton,
      #clearButton,
      #deleteButton {
         padding: 20px;
         margin-top: 8px;
         margin-left: 10px;
         border: 5px;
         cursor: pointer;
         border-radius: 5px;

      }
      #EqualButton {
         border-radius: 5px;
         height: 57px;
         border: 5px;
         padding-left: 10px;
         background-color: rgb(155, 197, 61); 
         font-size: 20px;
         font-weight: 500;

      }
      #result {
         border-radius: 5px;
         height: 55px;
         border: 5px;
         padding-left: 15px;
         color: black;
         font-size: 28px;
         font-weight: 500;


      }

      #operatorButton {
         background-color: rgb(245, 165, 114);
      }

      #deleteButton {
         background-color: rgb(255, 108, 92);
      }

      #clearButton {
         background-color: rgb(155, 81, 81);
      }

      .lastdiv {
         margin-left: 3px;
      }

      @media(max-width:580px) {
         .App-container {
            padding: 20px 0px;
            margin: 50% 6%;

         }
      }
   </style>
</head>

<body>
   <div class="App-container">
      <h1>Ezhil sree Calculator</h1>
      <h1>Reg No:212223230056</h1>

      <input type="text" id="result" placeholder="Enter Value..." readonly="" />
      <input type="button" id="EqualButton" value="Ans" onclick="SolveCalculation()" />
      <div>
         <input type="button" id="numberButton" value="7" onclick="display('7')" />
         <input type="button" id="numberButton" value="8" onclick="display('8')" />
         <input type="button" id="numberButton" value="9" onclick="display('9')" />
         <input type="button" id="operatorButton" value="/" onclick="display('/')" />
      </div>
      <div>
         <input type="button" id="numberButton" value="4" onclick="display('4')" />
         <input type="button" id="numberButton" value="5" onclick="display('5')" />
         <input type="button" id="numberButton" value="6" onclick="display('6')" />
         <input type="button" id="operatorButton" value="*" onclick="display('*')" />
      </div>
      <div>
         <input type="button" id="numberButton" value="1" onclick="display('1')" />
         <input type="button" id="numberButton" value="2" onclick="display('2')" />
         <input type="button" id="numberButton" value="3" onclick="display('3')" />
         <input type="button" id="operatorButton" value="-" onclick="display('-')" />
      </div>
      <div className='lastdiv'>
         <input type="button" id="numberButton" value="0" onclick="display('0')" />
         <input type="button" id="numberButton" value="." onclick="display('.')" />
        <input type="button" id="operatorButton" value="โˆš" onclick="squareRoot()" /> 
	     <input type="button" id="operatorButton" value="+" onclick="display('+')" />
      </div>
      <div>
         <input type="button" id='deleteButton' value="Del" onclick="deleteFuntion()" />
         <input type="button" id="clearButton" onclick="ClearFuntion()" value="C" />
	
      </div>
   </div>
</body>
</html>

OUTPUT:

Alt text Alt text

RESULT:

The program for designing a standard calculator using HTML and CSS is executed successfully.

calc's People

Contributors

ezhilsreej avatar selvasachein avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.