Code Monkey home page Code Monkey logo

calc's Introduction

Ex.08 Design of a Standard Calculator

Date:04.05.2024

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 :

<html>
<head>
    <title>Calculator</title>
    <link rel="stylesheet" href="cal.css">
</head>
<body>
    <div id="cal">
        <input  id="display" readonly>
        <div id="key">
            <button onclick="appendToDisplay('+')" class="operator-btn">+</button>
            <button onclick="appendToDisplay('7')" >7</button>
            <button onclick="appendToDisplay('8')" >8</button>
            <button onclick="appendToDisplay('9')" >9</button>


            <button onclick="appendToDisplay('-')" class="operator-btn">-</button>
            <button onclick="appendToDisplay('4')" >4</button>
            <button onclick="appendToDisplay('5')" >5</button>
            <button onclick="appendToDisplay('6')" >6</button>


            <button onclick="appendToDisplay('*')" class="operator-btn">*</button>
            <button onclick="appendToDisplay('1')" >1</button>
            <button onclick="appendToDisplay('2')" >2</button>
            <button onclick="appendToDisplay('3')" >3</button>

            <button onclick="appendToDisplay('/')" class="operator-btn">/</button>
            <button onclick="appendToDisplay('0')" >0</button>
            <button onclick="appendToDisplay('.')" >.</button>
            <button onclick="calculate()" >=</button>

            <button onclick="clearDisplay()" class="operator-btn">C</button>
            
        </div>
    </div>
    <script src="cal.js"></script>
</body>
</html>
 button
{
    width: 100px;
    height: 100px;
    border-radius: 50px;
    border: none;
    background-color: hsl(0, 0%,30%);
    color: white;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
}
button:hover
{
    background-color:orangered;
    transition: 2s;
}
button:active{
    background-color: red;
}
#key
{
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 10px;
    padding: 25px;
}
#cal
{
    font-family: 'Times New Roman';
    background-color: red;
    border-radius: 20px;
    max-width: 470px;
    overflow: hidden;
    color: black;


}
#display
{
    width: 100%; 
    padding: 20px; 
    font-size: 5rem; 
    text-align: left; 
    border: none; 
    background-color:hsl(0, 0%,20%);
    color: rgb(121, 42, 42);
}
body
{
    margin: 0; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    height: 100vh; 
    background-color:white
    ;
}
.operator-btn{ 
    background-color: hsl(39,100%,50%);
}
.operator-btn:hover{ 
    background-color: hsl(39,100%,65%);
}
.operator-btn:active{ 
    background-color: hsl(39,100%,75%);
}
var display=document.getElementById("display")

function appendToDisplay(input)
{
    display.value+=input
}
function cleardisplay()
{
    display.value="";
}
function calculate()
{
    try{
        display.value=eval(display.value);
    }
    catch(error)
    {
        display.value="Error";
    }
}

OUTPUT:

Screenshot 2024-04-29 213841 Screenshot 2024-04-29 213901

RESULT:

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

calc's People

Contributors

selvasachein avatar sakthivelrcse 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.