# loan.py id = input("Enter your ID (ddd-dd-dddd): ") while len(id)!=11 or id[3]!='-' or id[6]!='-' or\ not id[0].isdigit() or not id[1].isdigit() or not id[2].isdigit() or\ not id[4].isdigit() or not id[5].isdigit() or\ not id[7].isdigit() or not id[8].isdigit() or not id[9].isdigit() or not id[10].isdigit(): id = input("Invalid ID. \n Enter your ID (ddd-dd-dddd): ") cust_type = input("R(egular) or P(referred) customer: ").upper() while cust_type!='R' and cust_type!='P': cust_type = input("Invalid customer type.\n R(egular) or P(referred) customer: ").upper() if cust_type=='R': daily_interest_rate = 10/100/365 else: daily_interest_rate = 8/100/365 balance = float(input("Enter the initial loan: ")) while balance < 0: balance = float(input("Can not be negative!. \n Enter the initial loan: ")) payment_number = 1 previous_payday = 1 total_interest = 0 while balance > 0: payday = int(input("Enter pay day: ")) while payday < previous_payday: payday = int(input("Can not be before the previous payday.\n Enter pay day: ")) payment = float(input("Enter payment #"+str(payment_number)+": $")) while payment <= 0: payment = float(input("Must be a positive number.\n Enter payment #"+str(payment_number)+": $")) for day in range(previous_payday+1,payday+1): #each day's interest, compounding day_interest = balance*daily_interest_rate balance += day_interest total_interest += day_interest previous_payday = payday balance -= payment print(" Balance: $", round(balance,2)) payment_number += 1 print("\nYou paid off your loan in",(payment_number-1),"payments.") print("You paid a total interest of $"+str(round(total_interest,2))) if balance < 0: print("You overpaid, so $"+str(round(-balance,2))+" will be credited to your account.")