Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. '''
  2. The program talk about that simulate a simple bank account that has basic account transactions.
  3. Assniment 3
  4. student number:20186164
  5. Written by basel abdelhadi
  6. Modified by: basel abdelhadi
  7. Date: 19/October/2019
  8. '''
  9.  
  10. cust_acc = {'name': '', 'balance': ''} # Create an empty dictionary named "cust_acc" abrev. for (Customer_Accounts)
  11.  
  12. new_acc_prompt == cust_acc # define the new_acc_prompt as a string that can be used with option 1 in the menu
  13.  
  14.  
  15.  
  16. # for options 2-5 if the customer name with the account doesn't exist
  17. if new_acc_prompt != cust_acc : # you have to display this message : "This customer doesn't exist"
  18. print('This customer does not exist')
  19.  
  20. def menu():
  21.  
  22. ch = ''
  23. num = 0
  24.  
  25. while ch != 7:
  26. print("\tMAIN MENU")
  27. print("\t1. Open an account")
  28. print("\t2. Close an account")
  29. print("\t3. Deposit money")
  30. print("\t4. Withdrawal money")
  31. print("\t5. Enquire about balance")
  32. print("\t6. Print a list of customers and balances")
  33. print("\t7. Quit")
  34. print("\tSelect Your Option (1-7) ")
  35. ch = input()
  36.  
  37. if ch == '1':
  38. Open()
  39. elif ch =='2':
  40. Close()
  41. elif ch == '3':
  42. Deposit()
  43. elif ch == '4':
  44. Withdrawal()
  45. elif ch == '5':
  46. Enquire()
  47. elif ch == '6':
  48. listofcustomers()
  49. elif ch == '7':
  50. Quit()
  51. else :
  52. print("Unrecognized command")
  53.  
  54. ch = input("Enter your choice : ")
  55. menu()
  56.  
  57. # if your choice 1, open a new account, make sure the name doesn't exist
  58. def Open():
  59.  
  60. new_acc_prompt = int(input('Enter Name of the new customer and the amount of money to be deposited:'))
  61.  
  62. if new_acc_prompt != cust_acc :
  63. print('This customer does not exist')
  64.  
  65. print('into the new account (Ex.''):')
  66.  
  67. print('This customer account already exist!')
  68.  
  69.  
  70. # if your choice 2, close an account by name, make sure balance = 0 first
  71. def Close():
  72. new_acc_prompt = int(input('Enter the customer/account name to be deleted:'))
  73.  
  74. del cust_acc['new_acc_prompt']
  75.  
  76.  
  77. if new_acc_prompt != cust_acc :
  78. print('This customer does not exist')
  79.  
  80. if cust_acc > 0 :
  81. print('Can not close an account with balance greater than zero')
  82.  
  83. else:
  84. print('This account has been deleted successfully')
  85.  
  86.  
  87.  
  88.  
  89. # if your choice 3, deposit money, print balance before & after deposit
  90. def Deposit():
  91. new_acc_prompt = int(input('Enter the customer name for deposit:'))
  92.  
  93.  
  94. if new_acc_prompt != cust_acc :
  95. print('This customer does not exist')
  96.  
  97. d = int(input('Enter the amount to be deposited:'))
  98.  
  99. cust_acc.balance += balance
  100.  
  101. print('your balance is :',balance,'before deposit')
  102.  
  103. print('your balance is :', cust_acc ,'after deposit')
  104.  
  105.  
  106. # if your choice 4, Withdrawal money, make sure you have enough balance and print balance before & after the withdrawal
  107. def Withdrawal():
  108.  
  109. new_acc_prompt = int(input('Enter the customer name for withdrawal:'))
  110.  
  111.  
  112. if new_acc_prompt != cust_acc :
  113. print('This customer does not exist')
  114.  
  115.  
  116. w = int(input('Enter the amount to be withdrawn:'))
  117.  
  118.  
  119. print('your balance is :',balance ,'before withdrawal')
  120.  
  121. if w > cust_acc.balance:
  122. print('You do not have enough balance to cover the withdrawal')
  123.  
  124. cust_acc.balance -= balance
  125.  
  126.  
  127. print('your balance is :',balance ,'before withdrawal')
  128.  
  129. print('your balance is :' ,cust_acc , 'after withdrawal')
  130.  
  131.  
  132.  
  133. # if your choice 5, find a balance for a customer by name
  134. def Enquire():
  135.  
  136. new_acc_prompt = int(input('Enter the customer name for Balance enquiry:'))
  137.  
  138. if new_acc_prompt != cust_acc :
  139. print('This customer does not exist')
  140.  
  141. print('your balance is :', cust_acc.balance )
  142.  
  143.  
  144. # if your choice is 6, print a list of customer and balances, use given formats
  145. def listofcustomers():
  146.  
  147. print('No'' ''Customer'' ''Name'' ''Balance')
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154. # if your choice 7, exit the loop
  155. def Quit():
  156.  
  157. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement