def compound_interest(principal, rate, time, periods): amount = principal * (1 + rate / periods) ** (periods * time) interest = amount - principal return amount, interest def main(): principal = float(input("Enter Principal Amount (Rs.): ")) rate = float(input("Enter Annual Rate (as a decimal): ")) time = float(input("Enter Time Period: ")) period_unit = input("Enter Period Unit (e.g., years, months, days): ") periods = float(input(f"Enter Period Value (in {period_unit}): ")) total_amount, interest_earned = compound_interest(principal, rate, time, periods) print(f"\nTotal Amount after {time} {period_unit}: Rs. {total_amount:.2f}") print(f"Interest Earned: Rs. {interest_earned:.2f}") if __name__ == "__main__": main()

कोई टिप्पणी नहीं:

एक टिप्पणी भेजें