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万的情况

相关推荐
雪隐8 分钟前
用Flutter做背单词APP-01服务器?不存在的,我家里就有
前端·人工智能·后端
鹏易灵15 分钟前
C++——8.移动语义初探(移动构造、移动赋值)
开发语言·c++·php
2601_9623413027 分钟前
计算机毕业设计之jsp考研在线复习平台
java·大数据·开发语言·hadoop·python·考研·课程设计
凯瑟琳.奥古斯特28 分钟前
力扣1008:前序重建BST
开发语言·c++·算法·leetcode·职场和发展
用户22046039586841 分钟前
ES模块和commonJS两种标准下中实现__dirname?一篇文章教你理清楚
前端
2zcode1 小时前
项目文档:基于MATLAB图像处理的饮料瓶灌装液位检测系统设计与实现
开发语言·图像处理·matlab
云烟成雨TD1 小时前
LangFlow 1.x 系列【7】工作流创建与部署指南
人工智能·python·agent
犹豫的大炮1 小时前
jQuery最核心的基础设施之一——数据缓存模块进化史
前端·缓存·jquery
小碗细面1 小时前
从 PRD 到上线:SpecKit 如何让 AI 真正参与前端交付
前端·ai编程·claude
月疯1 小时前
np.where()[0]的用法
开发语言·python·numpy