Calculator web page using javascript

The Link Your Classhttps://bbs.csdn.net/forums/ssynkqtd-04
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/617332156
The Aim of This AssignmentMake an interface visual calculator
MU STU ID and FZU STU IDMU:21126674 ; FZU:832101214

1.The PSP form for this work

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning4550
• Estimate4550
Development405403
• Analysis2035
• Design Spec2530
• Design Review1517
• Coding Standard1512
• Design6055
• Coding150146
• Code Review6053
• Test6055
Reporting5059
• Test Repor2030
• Size Measurement1012
• Postmortem & Process Improvement Plan2017
Sum500512

2.Problem-solving ideas

First, I tried to understand the mission requirements. Read the questions carefully and determine the basic requirements of the calculator web page. This may include which mathematical operations are supported (such as addition, subtraction, multiplication, division, percentages, etc.), as well as the design requirements of the user interface (such as buttons, input fields, display areas, etc.).

Secondly, I collected the functional requirements for making a calculator web page and listed the required functions and operations. This can be a simple calculator or it can include advanced features such as history, bracket support, etc.

The third is interface design, thinking about how to design a clear, easy-to-use interface so that users can easily enter numbers and operators.

The next step is technology selection, determining the technology stack that will be used. This may include front-end technologies (such as HTML, CSS, JavaScript), the choice of frameworks and libraries, etc.

Then move on to the search information phase, using search engines to find tutorials, sample code, documentation, and resources related to making calculator web pages. Keywords include “Making calculator web tutorials”, “HTML forms”, “JavaScript calculator code”, etc., for systematic learning.

3.Design and implementation process

–Function–
在这里插入图片描述
–Flow chart of the key functions–
在这里插入图片描述

4.Code description

calc.html

<!DOCTYPE htm
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Calculator</title>
    <style>

        #top {
            width: 450px;
            height: 50px;
            margin: auto;
            background-color: rgb(251, 251, 251);
        }
        #top .point {
            width: 20px;
            height: 20px;
            float: left;
            margin-left: 10px;
            margin-top: 15px;
            border-radius: 10px;
        }
        #top .red {
            background-color: rgb(160, 0, 0);
        }
        #top .blue {
            background-color: blue;
        }
        #top .green {
            background-color: green;
        }
        #calc-title {
            font-size: 22px;
            color: white;
            float: right;
            margin-top: 10px;
            margin-right: 10px;
        }


        #result {
            width: 446px;
            height: 50px;
            margin: auto;
            text-align: right;
            background-color: white;
            border: solid 2px red;
            font-size: 30px;
        }


        #button {
            width: 450px;
            height: 422px;
            background-color: gray;
            margin: auto;
        }


        #button div {
            width: 108px;
            height: 80px;
            float: left;
            background-color: #fff;
            margin: 2px;
            line-height: 80px;
            text-align: center;
            font-size: 26px;
        }


        #button div:hover {
            background-color: orangered;
        }

    </style>
    <script src="./calc.js" type="text/javascript">
        
    </script>
</head>
<body >
    <div id="top">

        <div id="calc-title"></div>
    </div>

    <div id="result" name="result" ></div>

    <div id="button">

        <div onclick="qingkong()">AC</div>
        <div onclick="oper('/')">÷</div>
        <div onclick="oper('*')">*</div>
        <div onclick="doback()">CE</div>
        <div onclick="num(7)">7</div>
        <div onclick="num(8)">8</div>
        <div onclick="num(9)">9</div>
        <div onclick="oper('-')">-</div>
        <div onclick="num(4)">4</div>
        <div onclick="num(5)">5</div>
        <div onclick="num(6)">6</div>
        <div onclick="oper('+')">+</div>
        <div onclick="num(1)">1</div>
        <div onclick="num(2)">2</div>
        <div onclick="num(3)">3</div>
        <div></div>
        <div onclick="oper('%')">%</div>
        <div onclick="num(0)">0</div>
        <div onclick="oper('.')">.</div>
        <div onclick="yunsuan()">=</div>
    </div>

</body>
</html>

calc.js

function aler(){
    var cal = document.getElementById("calc-title").innerHTML;
    window.alert(cal);
    }
    document.getElementsByClassName("point");

    function num(number){
    var result = document.getElementById("result")
    result.innerHTML = result.innerHTML + number 
    }
 
    function oper(operator){
    var result = document.getElementById("result")
    result.innerHTML = result.innerHTML + operator
    }

    function yunsuan(){
        var result= document.getElementById("result")
        var expression = result.innerHTML
        result.innerHTML =eval(expression)
    }
    function doback(){
        var result =document.getElementById("result")
        var len=result.innerHTML.length
        result.innerHTML =result.innerHTML.substr(0,len-1)
        
    }
    function qingkong(){
        var result = document.getElementById("result")
        result.innerHTML = ""

    }

5.Achievement exhibition

20231009_221723

6.Summarization

In this task, I got familiar with the development knowledge and tools, learned the simple development process, and successfully created a simple and practical calculator web page. This study has fully exercised my programming ability and problem-solving ability, and I have learned how to find and fix errors. Also, making a calculator web page made me focus more on the user experience. I learned how to design friendly interfaces and how to make user operations simple and intuitive. This is important for any front-end project, and I believe that the experience of this attempt will be of great help in future front-end design.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值