A Calculator For Advanced Requirements

A Calculator For Advanced Requirements

Overall introduction

In terms of this blog,

1.Create a calculator with a visual interface.

2.Record necessary work content and process.

Link to the finished project code:

https://github.com/Aeolian12/-

Program Requirements:

1.Basic requirement: Implement addition, subtraction, multiplication, division, and clear functions.
2.Advanced requirement: Implement functionality for exponentiation, trigonometric functions, and more.

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 Assignmentan advanced calculator
MU STU ID and FZU STU IDMU:21124639 FZU:832101208

I. PSP form for this work

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning2020
• Estimate2020
Development150150
• Analysis1010
• Design Spec2020
• Design Review2020
• Coding Standard2020
• Design2020
• Coding3030
• Code Review1010
• Test2020
Reporting4040
• Test Repor1010
• Size Measurement1010
• Postmortem & Process Improvement Plan2020
Sum210210

II. Problem-solving ideas for designation

This is a simple task, so there should be many ways to solve this problem, the way I have chosen is through python language as the main programming method. The benefits are as follows:

  1. python language is an in-class program, so after systematic learning, it is more skillful in the programming stage.
  2. python is a higher level language, so there are simple and efficient libraries that can be used to solve this problem, which makes it easier to solve and less prone to bugs.
  3. Because not all users can run the .py file, so the .py file will be converted to an .exe file. Make it easy for users to use.

III. Practical implementation and process

Start
Enter number
Enter advanced Operators
Enter operator
Get the answer
clear
Withdrawal

IV. Code description

// number button 
btn7=tkinter.Button(root,text='7',command= lambda : pressnum('7'))
btn7.place(x=10,y=50,width=50,height=50)

btn8=tkinter.Button(root,text='8',command= lambda : pressnum('8'))
btn8.place(x=60,y=50,width=50,height=50)

btn9=tkinter.Button(root,text='9',command= lambda : pressnum('9'))
btn9.place(x=110,y=50,width=50,height=50)
//operator button
btnadd=tkinter.Button(root,text='+',command= lambda : presscal('+','+'))
btnadd.place(x=160,y=50,width=50,height=100)

btnsub=tkinter.Button(root,text='-',command= lambda : presscal('-','-'))
btnsub.place(x=210,y=50,width=50,height=100)

btnmul=tkinter.Button(root,text='x',command= lambda : presscal('*','x'))
btnmul.place(x=160,y=150,width=50,height=100)

btndiv=tkinter.Button(root,text='÷',command= lambda : presscal('/','÷'))
btndiv.place(x=210,y=150,width=50,height=100)
//advanced Operators button
btnsin=tkinter.Button(root,text='sin',command= lambda : presshigh('sin','sin'))
btnsin.place(x=160,y=250,width=50,height=50)

btncos=tkinter.Button(root,text='cos',command= lambda : presshigh('cos','cos'))
btncos.place(x=210,y=250,width=50,height=50)
//function
def pressnum(no):
    global numberornot
    global highornot
    highornot = 0
    numberornot=1
    oldno=num.get()
    if oldno.isdigit():
       if oldno=='0':
        num.set(no)
       else:
        num.set(oldno+no)
    else:
        num.set(no)

#high
def presshigh(sym1,sym2):
    global numberornot
    global steplist
    if numberornot==1:
        steplist.append(num.get())
    steplist.append(sym1)
    num.set(sym2)

    print(steplist)

#pi
def presspi():
    global numberornot
    global highornot
    if numberornot == 1:
        numberornot=0
        num.set('pi')
        steplist.append(str(math.pi))

#运算

def presscal(sym1,sym2):
    global numberornot
    global steplist
    if numberornot==1 :
        numberornot = 0

        steplist.append(num.get())
        steplist.append(sym1)
        num.set(sym2)


    print(steplist)


#等于
def pressequ():
    global numberornot
    global highornot
    highornot = 0
    if numberornot==1:
        numberornot = 0
        global steplist
        steplist.append(num.get())
        for i in range(len(steplist)):
            if steplist[i] == 'pi':
                steplist[i] = ''
        for b in range(len(steplist)):
            if steplist[b] == 'sin':
                steplist[b + 1] = str(math.sin(float(steplist[b + 1])))
                steplist[b] = ''
            elif steplist[b] == 'cos':
                steplist[b + 1] = str(math.cos(float(steplist[b + 1])))
                steplist[b] = ''
            elif steplist[b] == 'exp':
                steplist[b + 1] = str(math.exp(float(steplist[b + 1])))
                steplist[b] = ''
            elif steplist[b] == 'ln':
                steplist[b + 1] = str(math.log(float(steplist[b + 1])))
                steplist[b] = ''
        print(steplist)
        result = eval(''.join(steplist))

        num.set(result)
        steplist = []


#归零

def presszero():
    global steplist
    global highornot
    highornot = 0
    num.set(0)
    steplist=[]



#撤回

def presswith():
    global steplist
    global numberornot
    global highornot
    highornot = 0
    num.set(num.get()[:-1])
    if numberornot==0:
        steplist.pop()
        if steplist[-1].isdigit():
            numberornot=1


V. Display

在这里插入图片描述

VI. Summary

This software is an efficient calculator tool, developed using the Python programming language. It provides a user-friendly interface, enabling users to perform various mathematical operations such as addition, subtraction, multiplication, and division with ease. Not only limited to basic calculations, but this software is also capable of handling complex computations involving logarithmic, trigonometric, and exponential functions. Key features include a clean and intuitive design, high computation speed, and accurate results. With its focus on usability, this calculator software is suitable for both educational and professional uses, catering to a wide range of users from students to engineers. This software represents a perfect blend of Python’s power and simplicity, providing a reliable tool for all your calculation needs.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值