atm python program

Solutions on MaxInterview for atm python program by the best coders in the world

showing results for - "atm python program"
Vincenzo
03 Apr 2019
1   # ATM Processes
2   while True:
3 
4       # Reading id from user
5       id = int(input("\nEnter account pin: "))
6 
7       # Loop till id is valid
8       while id < 1000 or id > 9999:
9           id = int(input("\nInvalid Id.. Re-enter: "))
10 
11       # Iterating over account session
12       while True:
13 
14           # Printing menu
15           print("\n1 - View Balance \t 2 - Withdraw \t 3 - Deposit \t 4 - Exit ")
16 
17           # Reading selection
18           selection = int(input("\nEnter your selection: "))
19 
20           # Getting account object
21           for acc in accounts:
22               # Comparing account id
23               if acc.getId() == id:
24                   accountObj = acc
25                   break
26 
27           # View Balance
28           if selection == 1:
29               # Printing balance
30               print(accountObj.getBalance())
31 
32           # Withdraw
33           elif selection == 2:
34               # Reading amount
35               amt = float(input("\nEnter amount to withdraw: "))
36               ver_withdraw = input("Is this the correct amount, Yes or No ? " + str(amt) + " ")
37 
38               if ver_withdraw == "Yes":
39                   print("Verify withdraw")
40               else:
41                   break
42 
43               if amt < accountObj.getBalance():
44                  # Calling withdraw method
45                  accountObj.withdraw(amt)
46                  # Printing updated balance
47                  print("\nUpdated Balance: " + str(accountObj.getBalance()) + " n")
48               else:
49                    print("\nYou're balance is less than withdrawl amount: " + str(accountObj.getBalance()) + " n")
50                    print("\nPlease make a deposit.");
51 
52           # Deposit
53           elif selection == 3:
54               # Reading amount
55               amt = float(input("\nEnter amount to deposit: "))
56               ver_deposit = input("Is this the correct amount, Yes, or No ? " + str(amt) + " ")
57 
58               if ver_deposit == "Yes":
59                  # Calling deposit method
60                  accountObj.deposit(amt);
61                  # Printing updated balance
62                  print("\nUpdated Balance: " + str(accountObj.getBalance()) + " n")
63               else:
64                   break
65 
66           elif selection == 4:
67               print("nTransaction is now complete.")
68               print("Transaction number: ", random.randint(10000, 1000000))
69               print("Current Interest Rate: ", accountObj.annualInterestRate)
70               print("Monthly Interest Rate: ", accountObj.annualInterestRate / 12)
71               print("Thanks for choosing us as your bank")
72               exit()
73 
74           # Any other choice
75           else:
76               print("nThat's an invalid choice.")
77 
78# Main function
79main()
80
Gaia
21 Jan 2019
1account balance