# Ask the user for the loan amount
loan_amt: float = float(input("Please enter the loan amount: "))

# Ask the user for the monthly payment amount, we'll assume USD
payment: float = float(input("Please enter the monthly payment amount: "))

# Ask the user for the interest rate
interest: float = float(input("Please enter the interest rate: ")) / 100

# Calculate the monthly interest since we assume this compounds monthly
monthly_interest: float = interest / 12

# Create a variable to count the number of loops
month_count: int = 0

# Total Interest Paid
total_paid: float = 0

# Create the loop itself where you do the subtraction and print of each loop
while loan_amt > 0:
    month_count += 1
    interest_amt = loan_amt * monthly_interest
    total_paid += interest_amt
    principal_paid = min(payment - interest_amt, loan_amt)
    loan_amt -= principal_paid
    print(f"{month_count} | {interest_amt} | {principal_paid} | {loan_amt}")
    if loan_amt <= 0:
        break

# Print the final number of loops
print(
    f"It will take {month_count} month(s) or {month_count // 12} years to pay off this loan"
)
print(f"Total interest paid: {total_paid}")
