calculator 1

import tkinter as tk from tkinter import ttk, messagebox def calculate_corpus(): try: # Get input values goal_type = goal_var.get() current_cost = float(current_cost_entry.get()) child_age = int(child_age_entry.get()) target_age = int(target_age_entry.get()) inflation_rate = float(inflation_rate_entry.get()) expected_roi = float(expected_roi_entry.get()) # Validate input if target_age <= child_age: messagebox.showerror("Input Error", "Target age must be greater than current age.") return # Calculate years to goal years_to_goal = target_age - child_age # Future corpus needed future_corpus = current_cost * ((1 + inflation_rate / 100) ** years_to_goal) # Monthly SIP Calculation monthly_sip = (future_corpus * (expected_roi / 100) / 12) / (((1 + (expected_roi / 100) / 12) ** (years_to_goal * 12)) - 1) # Lump Sum Investment Calculation lump_sum_investment = future_corpus / ((1 + expected_roi / 100) ** years_to_goal) # Display results result_text.set(f" Future {goal_type} Corpus Needed: ₹{future_corpus:,.2f}\n" f" Monthly SIP Required: ₹{monthly_sip:,.2f}\n" f" Lump Sum Investment Required: ₹{lump_sum_investment:,.2f}") # Investment Suggestions if years_to_goal < 5: investment_suggestion.set(" Low-risk: FD, Debt Mutual Funds\n Medium-risk: Hybrid Mutual Funds\n High-risk: Direct Equity") elif years_to_goal < 10: investment_suggestion.set(" Low-risk: PPF, Debt Mutual Funds\n Medium-risk: Balanced Mutual Funds\n High-risk: Index Funds") else: investment_suggestion.set(" Low-risk: PPF, NPS\n Medium-risk: Mutual Funds (SIP)\n High-risk: Stocks, ETFs") except ValueError: messagebox.showerror("Input Error", "Please enter valid numerical values.") # Create GUI window root = tk.Tk() root.title("Education & Marriage Corpus Calculator") root.geometry("500x600") # Dropdown for goal selection goal_var = tk.StringVar(value="Education") ttk.Label(root, text="Select Goal:").pack() goal_dropdown = ttk.Combobox(root, textvariable=goal_var, values=["Education", "Marriage"]) goal_dropdown.pack() # Input Fields ttk.Label(root, text="Current Cost (₹):").pack() current_cost_entry = ttk.Entry(root) current_cost_entry.pack() ttk.Label(root, text="Child's Current Age (Years):").pack() child_age_entry = ttk.Entry(root) child_age_entry.pack() ttk.Label(root, text="Target Age for Goal (Years):").pack() target_age_entry = ttk.Entry(root) target_age_entry.pack() ttk.Label(root, text="Inflation Rate (%):").pack() inflation_rate_entry = ttk.Entry(root) inflation_rate_entry.pack() ttk.Label(root, text="Expected ROI (%):").pack() expected_roi_entry = ttk.Entry(root) expected_roi_entry.pack() # Calculate Button calculate_button = ttk.Button(root, text="Calculate", command=calculate_corpus) calculate_button.pack(pady=10) # Output Display result_text = tk.StringVar() result_label = ttk.Label(root, textvariable=result_text, wraplength=400) result_label.pack() investment_suggestion = tk.StringVar() suggestion_label = ttk.Label(root, textvariable=investment_suggestion, wraplength=400, foreground="blue") suggestion_label.pack() # Contact Details contact_label = ttk.Label(root, text="\n Need Expert Advice? Contact:\n Shravan Kumar Pippari\n Certified Insurance Advisor\n Mobile: +91 7207302015", foreground="green", wraplength=400) contact_label.pack() # Run the GUI root.mainloop()