0
def min_payment():
    ''' Calculates the minimum payment due on credit card
        depending on the credit card balance'''
    print("Tiny National Bank of Walterville")
    print("Credit Card Payments")


    balance = float(input("Please enter Credit Card Balance"))
    print("Credit Card Balance: " ,round(float(balance), 2))
    min1 = 12.00
    min2 = round(.027 * balance, 2)

    if min2 > min1:
        print("Minimum payment due: ", min2)

    elif balance <= 0:
        print("No payment due")

    elif balance < min1:
        print("Minimum payment due: ", balance)

    else:
        print("Minimum payment due: ", min1)    

If anyone can tell me how to loop that so I can repeat it based on user input, that would be very helpful. I basically want it to say something like this "Another customer (y or n)? "

Asking for the user to select y or n. Also please dont be too critical of the actual code. Im still learning. Its python by the way. Thanks!

2
  • If that's python, then where are indentations, by the way? Commented Nov 4, 2013 at 7:27
  • You loop it by adding a loop? Commented Nov 4, 2013 at 7:28

4 Answers 4

1
print("Tiny National Bank of Walterville")
print("Credit Card Payments")

while True:
    balance = float(input("Please enter Credit Card Balance"))
    print("Credit Card Balance: " ,round(float(balance), 2))
    min1 = 12.00
    min2 = round(.027 * balance, 2)

    if min2 > min1:
        print("Minimum payment due: ", min2)

    elif balance <= 0:
        print("No payment due")

    elif balance < min1:
        print("Minimum payment due: ", balance)

    else:
        print("Minimum payment due: ", min1)

    answer = ''
    while answer not in ('y', 'n'):
        answer = input("Another customer (y or n)").lower()
    if answer == 'n':
        break
Sign up to request clarification or add additional context in comments.

Comments

1
isDue=True

while isDue==True:

 balance = float(input("Please enter Credit Card Balance"))
 print("Credit Card Balance: " ,round(float(balance), 2))
 min1 = 12.00
 min2 = round(.027 * balance, 2)

 if min2 > min1:
    print("Minimum payment due: ", min2)

 elif balance <= 0:
     print("No payment due")

 elif balance < min1:
     print("Minimum payment due: ", balance)

 else:
     print("Minimum payment due: ", min1)

//set isDue = False somewhere in while loop

Comments

0

You can put while True; at the beginning, then take input from customer and if the customer says no make it switch to false.

Comments

0
Outstanding = 59400
interestrate = 4.2

#print("Month", "\t", "Interest+GST", "\t\t", "MinAmtDue", "\t\t\t", "Balance")
#print("-----", "\t\t", "-------", "\t\t", "--------", "\t\t\t", "-------")

month = 0
totpmt = 0
interest_GST = 0
minamtdue = 0
outstandingamt1 = Outstanding
while (outstandingamt1 + interest_GST - minamtdue) > 0 :
    month += 1
    interest_GST = outstandingamt1*4.2/100`enter code here`
    minamtdue = outstandingamt1 * 5/100
    #minamtdue = 12000enter code here
    outstandingamt1 = outstandingamt1 + interest_GST - minamtdue`enter code here`
    print(month, "\t\t\t", round(interest_GST,2), "\t\t", round(minamtdue,2), "\t\t\t", round(outstandingamt1,2))
    totpmt = totpmt + minamtdue
print(month+1, "\t\t\t", 0, "\t\t", round(outstandingamt1,2), "\t\t\t", 0)
print("Total Amount to be paid in ", month+1, "months= ", round(totpmt+outstandingamt1 , 2))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.