-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSISTEMA_BANCARIO.PY
65 lines (59 loc) · 2.08 KB
/
SISTEMA_BANCARIO.PY
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
menu = """\033[1m\033[37mCHOOSE ONE OF THE OPTIONS BELOW:
\033[32m[ 1 ] DEPOSIT
\033[34m[ 2 ] WITHDRAW
\033[33m[ 3 ] STATEMENT
\033[31m[ 4 ] EXIT\033[0m
=> """
balance = 0
limit = 500
statement = []
num_withdrawals = 0
withdrawal_limit = 3
def deposit(amount):
global balance
balance += amount
statement.append("\033[32mDeposit: $ {:.2f}\033[0m".format(amount))
print("\033[32mYou made a deposit of $ {:.2f}\033[0m".format(amount))
def withdraw(amount):
global balance, num_withdrawals
balance -= amount
statement.append("\033[34mWithdrawal: $ {:.2f}\033[0m".format(amount))
num_withdrawals += 1
def show_statement():
print("\033[33m°-°-" * 11)
print("\033[33mSTATEMENT")
if not statement:
print("No transactions have been made.")
else:
for transaction in statement:
print(transaction)
print("\nBalance: $ {:.2f}".format(balance))
print("\033[33m°-°-" * 11)
while True:
option = input(menu)
if option == "1":
amount = float(input("\033[37mEnter the deposit amount: "))
if amount > 0:
deposit(amount)
else:
print("\033[31mInvalid operation. The amount entered is invalid.\033[0m")
elif option == "2":
amount = float(input("\033[37mEnter the withdrawal amount: "))
if amount > 0:
if amount > balance:
print("\033[31mOperation failed! You do not have sufficient funds.\033[0m")
elif amount > limit:
print("\033[31mOperation failed! The withdrawal amount exceeds the limit.\033[0m")
elif num_withdrawals >= withdrawal_limit:
print("\033[31mOperation failed! Maximum number of withdrawals reached.\033[0m")
else:
withdraw(amount)
else:
print("\033[31mOperation failed! The amount is invalid.\033[0m")
elif option == "3":
show_statement()
elif option == "4":
print("\033[31mOPERATION TERMINATED! COME BACK SOON.\033[0m")
break
else:
print("\033[31mINVALID INFORMATION. PLEASE TRY AGAIN.\033[0m")