OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Program to check Credit Card balance using user input spec. looping a request for 'yes' or 'no' response from user [duplicate]

  • Thread starter Thread starter Matthew William Barnes
  • Start date Start date
M

Matthew William Barnes

Guest
I am writing a program that guides users through making a payment on their credit card but, I am running into problems when the user enters anything other than 'yes' or 'no' when asked if they would like to make a payment.

I tried

Code:
def Credit_card():
    ccb=float(input("What is your credit card balance?\n"))
    pur=float(input("How much have you spent in purchases?\n"))
    minpymt=pur*.12
    print("Your minimum payment is ${0}".format(minpymt))
    dectopay=input("Would you like to make a payment?\n Please type 'yes' or 'no'\n")
    while (dectopay!='yes'or'no'):
           input("We're sorry. You must answer either 'yes' or 'no'.\n Would you like to make a payment?\n")
    if(dectopay=="yes"):
        pymt=float(input("Wonderful! How much would you like to pay?\n"))
        while(pymt<minpymt):
          pymt=float(input("We're sorry, but your payment must be greater than or equal to your minimum payment of ${0}\nHow much would you like to pay?\n").format(minpymt))
        print("Thank you for your payment!\n")
        print("Your new credit card balance is ${0}\n".format((ccb+pur)-pymt))     
    elif(dectopay=="no"):
        print("Your credit card balance is ${0}. Thank you for visiting Credit Central. \n Have a wonderful day!".format(ccb+pur))


           
    
Credit_card()

Which, after I enter 'yes' or 'no' I was hoping the loop would cancel. The condition for the loop is that:

Code:
(dectopay!='yes'or'no')

which should end if they do equal either yes or no right?

Let me know. I am gonna skip this sidequest and continue with some html/css/java stuff because getting stuck on such a mundane task seems like a waste of time. I still want the program to do what I want though.

Thanks for any help.
<p>I am writing a program that guides users through making a payment on their credit card but, I am running into problems when the user enters anything other than 'yes' or 'no' when asked if they would like to make a payment.</p>
<p>I tried</p>
<pre><code>def Credit_card():
ccb=float(input("What is your credit card balance?\n"))
pur=float(input("How much have you spent in purchases?\n"))
minpymt=pur*.12
print("Your minimum payment is ${0}".format(minpymt))
dectopay=input("Would you like to make a payment?\n Please type 'yes' or 'no'\n")
while (dectopay!='yes'or'no'):
input("We're sorry. You must answer either 'yes' or 'no'.\n Would you like to make a payment?\n")
if(dectopay=="yes"):
pymt=float(input("Wonderful! How much would you like to pay?\n"))
while(pymt<minpymt):
pymt=float(input("We're sorry, but your payment must be greater than or equal to your minimum payment of ${0}\nHow much would you like to pay?\n").format(minpymt))
print("Thank you for your payment!\n")
print("Your new credit card balance is ${0}\n".format((ccb+pur)-pymt))
elif(dectopay=="no"):
print("Your credit card balance is ${0}. Thank you for visiting Credit Central. \n Have a wonderful day!".format(ccb+pur))




Credit_card()
</code></pre>
<p>Which, after I enter 'yes' or 'no' I was hoping the loop would cancel. The condition for the loop is that:</p>
<pre><code>(dectopay!='yes'or'no')
</code></pre>
<p>which should end if they do equal either yes or no right?</p>
<p>Let me know. I am gonna skip this sidequest and continue with some html/css/java stuff because getting stuck on such a mundane task seems like a waste of time. I still want the program to do what I want though.</p>
<p>Thanks for any help.</p>
 

Latest posts

B
Replies
0
Views
1
Blundering Ecologist
B
Top