-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.py
More file actions
151 lines (133 loc) · 5.58 KB
/
Copy pathATM.py
File metadata and controls
151 lines (133 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
user_id=""
user_pass=""
atm_pin=0
balance=0
login_success = False
mini_statement= ""
count=0
todays_limit=100000
total_rewards = 0
while True:
print("\n========== SMART ATM SYSTEM ==========\n1 → Register\n2 → Login\n3 → Deposit Money\n4 → Withdraw Money\n5 → Check Balance\n6 → Mini Statement\n7 → Change PIN\n8 → Cashback Rewards\n9 → Logout\n0 → Exit")
choice = int(input("\nEnter your choice: "))
match choice:
case 1:
user_id = input("Enter User Id: ").lower()
user_pass = input("Enter User Password: ")
atm_pin = int(input("Enter ATM PIN: "))
balance = float(input("Enter Inital Amount: "))
deposit = balance
count+=1
mini_statement = mini_statement + "\n"+str(count)+". Initialy_Deposited: " + str(deposit)+"$"
if deposit>=10000:
I_reward =deposit/50
total_rewards += I_reward
balance+=I_reward
count+=1
mini_statement = mini_statement + "\n"+str(count)+". Cashback Reward: " + str(I_reward)+"$"
print("Congratulations! , 2% Cashback added!")
else:
print("Deposit atleast 10,000$, to get 2% cashback")
case 2:
if login_success==True:
print("You are already logged in!")
elif user_id == "":
print("Please Register!")
else:
attempts = 3
login_success = False
while attempts > 0:
user1_id = input("Enter User Id: ").lower()
user1_pass = input("Enter User Password: ")
atm1_pin = int(input("Enter ATM PIN: "))
if (user_id, user_pass, atm_pin) == (user1_id, user1_pass, atm1_pin):
print("Login successful, You can proceed...")
login_success = True
break
else:
attempts -= 1
print(f"\nInvalid Credentials\n{attempts} attempts left!")
if not login_success:
print("\nMaximum limit of attempts reached!")
print("Thank You for Visiting.")
break
case 3:
if login_success==False:
print("Please Login and retry")
else:
deposit = float(input("Enter amount to Deposit: $"))
balance+=deposit
print(f"Successfully deposited {deposit}$ :)")
count+=1
mini_statement = mini_statement + "\n"+str(count)+". Deposited: " + str(deposit)+"$"
if deposit>=10000:
print("Congratulations , 2% Cashback added!")
D_reward = deposit/50
total_rewards += D_reward
balance+=D_reward
count+=1
mini_statement = mini_statement + "\n"+str(count)+". Cashback Reward: " + str(D_reward)+"$"
case 4:
if login_success==False:
print("Please Login and retry")
else:
withdraw = float(input("Enter amount to Withdraw: $"))
if withdraw > balance:
print("Insufficient balance.\nPlease recheck your amount!")
elif withdraw > todays_limit:
print("Maximum withdrawal limit reached for today!")
else:
balance -= withdraw
todays_limit -= withdraw
count += 1
mini_statement += "\n" + str(count) + ". Withdrawed: " + str(withdraw) + "$"
print(f"Successfully withdrawed {withdraw}$ ;)")
case 5:
if login_success==False:
print("Please Login and retry")
else:
print(f"Balance: {balance}")
case 6:
if login_success==False:
print("Please Login and retry")
else:
print("\n-----Mini Statement------",mini_statement)
case 7:
if login_success==False:
print("Please Login and retry")
else:
pin_attempts=3
while pin_attempts>0:
current_pin = int(input("Enter Current PIN: "))
if atm_pin==current_pin:
new_pin= int(input("Enter New PIN: "))
atm_pin = new_pin
print("PIN successfully updated!")
break
else:
pin_attempts-=1
print(f"Please Enter valid PIN\n{pin_attempts} attempts left!")
if pin_attempts==0:
print("Invalid Login detected!")
break
case 8:
if login_success == False:
print("Please Login and retry")
else:
print("\n----- Cashback Rewards -----")
print(f"Total Cashback Earned: {total_rewards}$")
case 9:
if login_success == False:
print("No active session found!")
else:
login_success = False
print("Logged out successfully!")
withdraw = 0
deposit = 0
case 0:
print("\nSaving Session...")
print("Exiting Smart ATM System")
print("Thank You for Visiting!")
break
case _:
print("Please enter valid choice")