python实现存款日利息计算器(窗口界面形式)

输入存款金额,7日年化收益率,输出每日利息

完整源码如下:

复制代码
import tkinter as tk
from tkinter import messagebox

def calculate_interest():
    deposit = float(entry_deposit.get())
    interest_rate = float(entry_interest_rate.get())

    daily_interest_rate = interest_rate / 365  # 计算每日利率
    daily_interest = round(deposit * daily_interest_rate, 2)  # 计算每日收益并保留两位小数

    result_label.config(text=f"每天的收益为:{daily_interest}")

# 创建窗口
window = tk.Tk()
window.title("存款利息计算器")
window.geometry("400x200")  # 设置窗口大小

# 创建标签和输入框
label_deposit = tk.Label(window, text="存款金额:")
label_deposit.pack()
entry_deposit = tk.Entry(window)
entry_deposit.pack()

label_interest_rate = tk.Label(window, text="7日年化收益率:")
label_interest_rate.pack()
entry_interest_rate = tk.Entry(window)
entry_interest_rate.pack()

# 创建按钮
button_calculate = tk.Button(window, text="计算", command=calculate_interest)
button_calculate.pack()

# 创建结果标签
result_label = tk.Label(window, text="每天的收益为:")
result_label.pack()

# 运行窗口
window.mainloop()

运行结果如下:

10万和1000万的情况

相关推荐
2601_9491465317 分钟前
C语言语音通知接口接入教程:如何使用C语言直接调用语音预警API
c语言·开发语言
曹牧23 分钟前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
passerby606127 分钟前
完成前端时间处理的另一块版图
前端·github·web components
KYGALYX29 分钟前
服务异步通信
开发语言·后端·微服务·ruby
掘了34 分钟前
「2025 年终总结」在所有失去的人中,我最怀念我自己
前端·后端·年终总结
zmzb010335 分钟前
C++课后习题训练记录Day98
开发语言·c++
崔庆才丨静觅37 分钟前
实用免费的 Short URL 短链接 API 对接说明
前端
ValhallaCoder38 分钟前
hot100-二叉树I
数据结构·python·算法·二叉树
崔庆才丨静觅1 小时前
5分钟快速搭建 AI 平台并用它赚钱!
前端
猫头虎1 小时前
如何排查并解决项目启动时报错Error encountered while processing: java.io.IOException: closed 的问题
java·开发语言·jvm·spring boot·python·开源·maven