Advertisement
IMustRemainUnknown

Withdraw and Deposit

Nov 24th, 2023
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.39 KB | Source Code | 0 0
  1. Max = 10000  # Max withdraw allowed is 10000
  2. deposit_input = input("Enter the number of denominations to be deposited: ")
  3.  
  4. # deposit part
  5. L = deposit_input.split(",")
  6. deposit = [int(d) for d in L]
  7.  
  8. # conversion of the user input deposit
  9. d_20, d_50, d_100, d_200, d_500, d_1000 = deposit
  10.  
  11. total = (d_20 * 20) + (d_50 * 50) + (d_100 * 100) + (d_200 * 200) + (d_500 * 500) + (d_1000 * 1000)
  12.  
  13. print("Your starting balance is:", total, "pesos")
  14.  
  15. withdrawing = True
  16.  
  17. while withdrawing:
  18.  
  19.     condition = True
  20.  
  21.     d_20, d_50, d_100, d_200, d_500, d_1000 = deposit
  22.  
  23.     d_20check = d_20
  24.     d_50check = d_50
  25.     d_100check = d_100
  26.     d_200check = d_200
  27.     d_500check = d_500
  28.     d_1000check = d_1000
  29.  
  30.     total = (d_20 * 20) + (d_50 * 50) + (d_100 * 100) + (d_200 * 200) + (d_500 * 500) + (d_1000 * 1000)
  31.  
  32.     while condition:
  33.         proceed = True
  34.         wit = input("Enter the amount you want to withdraw: ")
  35.         withd = int(wit)
  36.         reversed_num = str(withd)[::-1]
  37.         digits = [int(digit) for digit in str(reversed_num)]
  38.  
  39.         withdcheck = withd
  40.  
  41.         if 0 < digits[0] < 10 or digits[1] == 1:
  42.             print("Invalid Amount Inputted")
  43.         else:
  44.             if 0 < withdcheck <= Max:
  45.                 while withdcheck > 0:
  46.                     if d_1000check > 0 and withdcheck >= 1000:
  47.                         dispensedcheck = withdcheck // 1000
  48.                         withdcheck -= dispensedcheck * 1000
  49.                         d_1000check -= dispensedcheck
  50.  
  51.                     elif d_500check > 0 and withdcheck >= 500:
  52.                         dispensedcheck = withdcheck // 500
  53.                         withdcheck -= dispensedcheck * 500
  54.                         d_500check -= dispensedcheck
  55.  
  56.                     elif d_200check > 0 and withdcheck >= 200:
  57.                         dispensedcheck = withdcheck // 200
  58.                         withdcheck -= dispensedcheck * 200
  59.                         d_200check -= dispensedcheck
  60.  
  61.                     elif d_100check > 0 and withdcheck >= 100:
  62.                         dispensedcheck = withdcheck // 100
  63.                         withdcheck -= dispensedcheck * 100
  64.                         d_100check -= dispensedcheck
  65.  
  66.                     elif d_50check > 0 and withdcheck >= 50:
  67.                         dispensedcheck = withdcheck // 50
  68.                         withdcheck -= dispensedcheck * 50
  69.                         d_50check -= dispensedcheck
  70.  
  71.                     elif d_20check > 0 and withdcheck >= 20:
  72.                         dispensedcheck = withdcheck // 20
  73.                         withdcheck -= dispensedcheck * 20
  74.                         d_20check -= dispensedcheck
  75.  
  76.                     else:
  77.                         proceed = False
  78.                         print("Invalid withdrawal amount!")
  79.                         break
  80.  
  81.                 if proceed == True:
  82.                     while withd > 0:
  83.  
  84.                         if d_1000 > 0 and withd >= 1000:
  85.                             dispensed = withd // 1000
  86.                             withd -= dispensed * 1000
  87.                             d_1000 -= dispensed
  88.                             print("Dispensing", dispensed, "1000-peso banknotes.")
  89.  
  90.                         elif d_500 > 0 and withd >= 500:
  91.                             dispensed = withd // 500
  92.                             withd -= dispensed * 500
  93.                             d_500 -= dispensed
  94.                             print("Dispensing", dispensed, "500-peso banknotes.")
  95.  
  96.                         elif d_200 > 0 and withd >= 200:
  97.                             dispensed = withd // 200
  98.                             withd -= dispensed * 200
  99.                             d_200 -= dispensed
  100.  
  101.                             print("Dispensing", dispensed, "200-peso banknotes.")
  102.  
  103.                         elif d_100 > 0 and withd >= 100:
  104.                             dispensed = withd // 100
  105.                             withd -= dispensed * 100
  106.                             d_100 -= dispensed
  107.  
  108.                             print("Dispensing", dispensed, "100-peso banknotes.")
  109.  
  110.                         elif d_50 > 0 and withd >= 50:
  111.                             dispensed = withd // 50
  112.                             withd -= dispensed * 50
  113.                             d_50 -= dispensed
  114.  
  115.                             print("Dispensing", dispensed, "50-peso banknotes.")
  116.  
  117.                         elif d_20 > 0 and withd >= 20:
  118.                             dispensed = withd // 20
  119.                             withd -= dispensed * 20
  120.                             d_20 -= dispensed
  121.                             print("Dispensing", dispensed, "20-peso banknotes.")
  122.  
  123.  
  124.  
  125.                         else:
  126.                             print("Invalid withdrawal amount!")
  127.                             break
  128.  
  129.                     balance = total - int(wit)
  130.                     total = balance  # Update the total to the new balance
  131.                     print("Available balance:", balance, "pesos")
  132.  
  133.  
  134.             else:
  135.                 print(
  136.                     "Invalid withdrawal amount. The maximum withdrawal amount is 10,000 pesos. Please enter a valid amount.")
  137.  
  138.         decision = input("Do you want to withdraw again? (Y/N) ")
  139.  
  140.         if decision == "Y":
  141.             continue
  142.         else:
  143.             condition = False
  144.             print("THANK YOU FOR BANKING!\nAvailable balance: ", total)
  145.             break
  146.  
  147.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement