HTML
import tkinter as tk from tkinter import messagebox # Create the main window root = tk.Tk() root.title("Loan Management System") # Create the labels and entry fields label_name = tk.Label(root, text="Name:") label_name.grid(row=0, column=0) entry_name = tk.Entry(root) entry_name.grid(row=0, column=1) label_loan_amount = tk.Label(root, text="Loan Amount:") label_loan_amount.grid(row=1, column=0) entry_loan_amount = tk.Entry(root) entry_loan_amount.grid(row=1, column=1) label_interest_rate = tk.Label(root, text="Interest Rate:") label_interest_rate.grid(row=2, column=0) entry_interest_rate = tk.Entry(root) entry_interest_rate.grid(row=2, column=1) label_duration = tk.Label(root, text="Duration (in months):") label_duration.grid(row=3, column=0) entry_duration = tk.Entry(root) entry_duration.grid(row=3, column=1) # Function to calculate the monthly installment def calculate_installment(): try: loan_amount = float(entry_loan_amount.get()) interest_rate = float(entry_interest_rate.get()) duration = int(entry_duration.get()) interest = loan_amount * interest_rate / 100 total_amount = loan_amount + interest monthly_installment = total_amount / duration messagebox.showinfo("Result", "Monthly Installment: ${:.2f}".format(monthly_installment)) except ValueError: messagebox.showerror("Error", "Invalid input. Please enter numeric values.") # Create the calculate button calculate_button = tk.Button(root, text="Calculate", command=calculate_installment) calculate_button.grid(row=4, column=0, columnspan=2) # Start the main event loop root.mainloop()