This Python program calculates the total profit earned by a policyholder over a number of years.
Inputs required:
- Investment amount
- Annual profit rate (as a percentage)
- Number of years
The program uses simple interest to compute the total profit and final amount.
# Read inputs from user
investment = float(input("Enter investment amount: "))
annual_rate = float(input("Enter annual profit rate (%): "))
years = int(input("Enter number of years: "))
# Calculate total profit
profit = investment * annual_rate / 100 * years
final_amount = investment + profit
# Display results
print(f"\nTotal profit over {years} years: {profit:.2f}")
print(f"Final amount after {years} years: {final_amount:.2f}")
Enter investment amount: 1000000
Enter annual profit rate (%): 12
Enter number of years: 5
Total profit over 5 years: 600000.00
Final amount after 5 years: 1600000.00
- The user enters the initial investment, profit rate, and duration
- The program calculates simple interest using the formula:
profit = investment × rate × years / 100
- The final amount is the sum of the original investment and the total profit
- Results are displayed with two decimal places for clarity