Untitled
unknown
plain_text
a year ago
12 kB
12
Indexable
import json
accounts=[]
def Deposit():
dipo=input("Please enter the amount you want to deposit and the currency in this format '1 EGY' : \n")
printer = dipo
dipo = dipo.split(' ')
while len(dipo) != 2:
dipo = input('please enter the amount you want to transfer in this format "1 EGY" : \n')
dipo = dipo.split(' ')
dipo[1]=dipo[1].upper()
while dipo[1] not in ["SAR", "USD", "EGY"]:
print("we just use (SAR , EGY , USD)")
dipo = input("Please enter the amount you want to deposit and the currency in this format '1 EGY' : \n")
printer = dipo
dipo = dipo.split(' ')
dipo[1] = dipo[1].upper()
if dipo[1]=="EGY":
accounts[id]["balance"]+=int(dipo[0])
print(f"{printer} was Deposit successfully \n Your balance is {accounts[id]["balance"]} ")
elif dipo[1] == "USD":
accounts[id]["balance"] += int(dipo[0])*30
print(f"{printer} was Deposit successfully \n Your balance is {accounts[id]["balance"]} ")
elif dipo[1] == "SAR":
accounts[id]["balance"] += int(dipo[0])*10
print(f"{printer} was Deposit successfully \n Your balance is {accounts[id]["balance"]} ")
file=open("data.json","w")
json.dump(accounts,file,indent=2)
file.close()
def Withdraw():
wit = input("Please enter the amount you want to withdraw and the currency in this format '1 EGY' : \n")
wit=wit.upper()
printer=wit
wit = wit.split(' ')
while wit[1] not in ["SAR","USD","EGY"] :
print ("we jast use (SAR , EGY , USD)")
wit = input("Please enter the amount you want to deposit and the currency in this format '1 EGY' : \n")
printer = wit
wit = wit.split(' ')
wit = wit.upper()
if wit[1] == "EGY":
if accounts[id]["balance"] >= int(wit[0]):
accounts[id]["balance"] -= int(wit[0])
print(f"{printer} was withdraw successfully \n Your balance is {accounts[id]["balance"]} ")
else:
print(f"Your balance is less than what you want to withdraw \nYour balance is {accounts[id]["balance"]} ")
elif wit[1] == "USD":
if accounts[id]["balance"] >= int(wit[0])*30:
accounts[id]["balance"] -= int(wit[0])*30
print(f"{printer} was withdraw successfully \n Your balance is {accounts[id]["balance"]} EGY")
elif accounts[id]["balance"] < int(wit[0])*30:
print(f"Your balance is less than what you want to withdraw \nYour balance is {accounts[id]["balance"]} EGY ")
elif wit[1] == "SAR":
if accounts[id]["balance"] >= int(wit[0])*10:
accounts[id]["balance"] -= int(wit[0])*10
print(f"{printer} was withdraw successfully \n Your balance is {accounts[id]["balance"]} EGY")
elif accounts[id]["balance"] < int(wit[0])*10 :
print(f"Your balance is less than what you want to withdraw \nYour balance is {accounts[id]["balance"]} EGY ")
file = open("data.json", "w")
json.dump(accounts, file, indent=2)
file.close()
file=open("data.json","r")
accounts=json.load(file)
file.close()
userID=0
x=0
print('welcom to the sic bank management sysytem')
print('Enter login to login')
print('Enter register to creat new account')
print('Enter exit to end the programme')
choice =input("please choose an option : \n")
choice=choice.lower()
while choice != "login" and choice != "register" and choice!= "exit":
choice = input("invalid choice ,\n please Enter your gender (login or register or exit) : ")
choice = choice.lower()
id=len(accounts)
if choice == 'login':
userID=input('please enter your ID : ')
while userID.isdigit()==False :
userID = input('invalid ID please, \nenter valid id ID : ')
userID=int(userID)
while userID > len(accounts)-1:
print("Your id is not exist or password is incorrect")
userID = input('please enter your ID : ')
while userID.isdigit() == False:
userID = input('invalid ID please, \nenter valid id ID : ')
userID=int(userID)
password = input('please enter your password : ')
userID=int(userID)
while userID != accounts[userID]["id"] or password !=accounts[userID]["Password"] :
print('incorrect ID of password , please try again')
userID = int(input('please enter your ID : \n'))
password = input('please enter your password : \n')
if userID == accounts[userID]["id"] and password == accounts[userID]["Password"] :
print("login successful")
id = userID
x=1
elif choice == 'register':
dict = {}
print("****************** Welcome to SignUp page ******************")
name = input("please Enter your name : ")
password = input("please Enter your password : ")
while not (8<=len(password)<=32) or (password.isalpha()==True) :
password = input("invalid password,\nplease make sure Enter a valid password between 8 to 32 and enter at least 1 number or space : ".upper())
num = input("please Enter your phone number : ")
while len(num) != 11 or num.isdigit()==False :
num = input("invalid phon number please Enter your phone number : ")
sure="@gmail.com"
mail = input("please Enter your Mail : ")
x=mail.lower()
while sure not in x or sure == x :
print("invalid mail, please enter your mail with @gmail.com ")
mail = input("please Enter your Mail : ")
x=mail.lower()
gen = input("please Enter your gender : ")
while gen.lower()!="male" and gen.lower() !="female":
gen = input("invalid gender ,\n please Enter your gender (male or female) : ")
age = input("please Enter your age : ")
while age.isdigit()==False :
age = input('invalid age please, \nenter a valid age : ')
age = int(age)
while not 7 < age < 100 :
age = input('invalid age please, \nenter a your real age : ')
while age.isdigit() == False:
age = input('invalid age please, \nenter a valid age : ')
age = int(age)
if age.isdigit() == True :
age = int(age)
city = input("please Enter your city : ")
dict = {
"Name": name,
"Password": password,
"Phone number": num,
"Mail": mail,
"Gender": gen,
"Age": age,
"City": city,
"balance": 0,
"id" : id
}
accounts.append(dict)
print (f"Sign up successful , your id is {id}")
x=1
file = open("data.json", "w")
json.dump(accounts, file, indent=2)
file.close()
userID=id
if choice == 'exit' :
print("Thank you for using SIC Bank, We hope to see you soon ".upper())
exit()
if x == 1 :
while True :
print (f"**********************Wlcome back {accounts[id]["Name"]}**********************\nPlease enter your choice")
cho=input("[0]Deposit\n[1]Withdraw\n[2]Transfer\n[3]Check balance & Personal info\n[4]Exit\n")
while cho not in ["0","1","2","3","4"]:
print ("Please enter an number btween 0 to 4")
cho = input("[0]Deposit\n[1]Withdraw\n[2]Transfer\n[3]Check balance & Personal info\n[4]Exit\n")
if cho=='4':
exit()
elif cho == '0':
Deposit()
elif cho == '1' :
Withdraw()
elif cho =='2':
transferAMOUNT = input('please enter the amount you want to transfer in this format "1 EGY" : \n')
transferAMOUNT = transferAMOUNT.split(' ')
accountID = int(input('please enter the ID of the account you want to transfer money to '))
while len(transferAMOUNT) != 2 :
transferAMOUNT = input('please enter the amount you want to transfer in this format "1 EGY" : \n')
transferAMOUNT = transferAMOUNT.split(' ')
transferAMOUNT[1]=transferAMOUNT[1].upper()
while transferAMOUNT[1] not in ["EGY","SAR","USD"] :
print("We only use three currencies of countries")
transferAMOUNT = input('please enter the amount you want to transfer in this format "1 EGY" : \n')
transferAMOUNT = transferAMOUNT.split(' ')
sum = int(transferAMOUNT[0])
if transferAMOUNT[1] == "EGY":
while len (accounts) <= accountID or accounts[userID]["balance"] < int(transferAMOUNT [0]) :
print('insufficient balance or incorrect ID, please try again')
transferAMOUNT = input('please enter the amount you want to transfer in this format "1 EGY" : \n')
transferAMOUNT = transferAMOUNT.split(' ')
accountID = int(input('please enter the ID of the account you want to transfer money to : \n'))
accounts[userID]["balance"] -= int(transferAMOUNT[0])
accounts[accountID]["balance"] += int(transferAMOUNT[0])
print(f'{sum} EGP was transferred succefully!')
print(f'your balance is {accounts[userID]["balance"]} EGP')
elif transferAMOUNT[1] == "USD":
while len(accounts) <= accountID or accounts[userID]["balance"] < sum *30:
print('insufficient balance or incorrect ID, please try again')
transferAMOUNT = input('please enter the amount you want to transfer in this format "1 EGY" : \n')
transferAMOUNT = transferAMOUNT.split(' ')
accountID = int(input('please enter the ID of the account you want to transfer money to : \n'))
accounts[userID]["balance"] -= sum*30
accounts[accountID]["balance"] += int(transferAMOUNT[0])*30
print(f'{sum * 30} EGP was transferred succefully! to {accounts[accountID]["balance"]}')
print(f'your balance is {accounts[userID]["balance"]} EGP')
elif transferAMOUNT[1] == 'SAR':
while len(accounts) <= accountID or accounts[userID]["balance"] < sum*10:
print('insufficient balance or incorrect ID, please try again')
transferAMOUNT = input('please enter the amount you want to transfer in this format "1 EGY" : \n')
transferAMOUNT = transferAMOUNT.split(' ')
accountID = int(input('please enter the ID of the account you want to transfer money to : \n'))
accounts[userID]["balance"] -= sum*10
accounts[accountID]["balance"] += sum*10
print(f'{sum * 10} EGP was transferred succefully! to {accounts[accountID]["balance"]}')
print(f'your balance is {accounts[userID]["balance"]} EGP')
file = open("data.json", "w")
json.dump(accounts, file, indent=2)
file.close()
elif cho == '3':
print(f"ID : {accounts[id]["id"]}\nName : {accounts[id]["Name"]}\nphone number : {accounts[id]["Phone number"]}\nMail : {accounts[id]["Mail"]}")
print(f"Gender : {accounts[id]["Gender"]}\nAge : {accounts[id]["Age"]}\nCity : {accounts[id]["City"]}\nBalance : {accounts[id]["balance"]}")Editor is loading...
Leave a Comment