INPUT :
OUTPUT TAMPILAN AWAL :
OUTPUT 2.TRANSFER UANG :
OUTPUT 3.AMBIL UANG :
OUTPUT 4.LOGOUT :
OUTPUT PIN SALAH :
OUTPUT NO REKENING SALAH :
OUTPUT TARIK SALDO TIDAK CUKUP :
Script Python :
user_id = 0
loop = "n"
users = [
{
"id": "0001",
"no_rekening": "1234567890",
"username": "Nanda",
"pin": "4321",
"saldo": 0
},
{
"id": "0002",
"no_rekening": "0987654321",
"username": "Kurniawan",
"pin": "1234",
"saldo": 25000000
},
{
"id": "0003",
"no_rekening": "012349876",
"username": "Mongex",
"pin": "1122",
"saldo": 2000000
}
]
status_login = False
pakai_atm = "y"
def cek_login(p):
for user in users:
if user['pin'] == p:
return user
return False
def cek_user(id):
for i in range(len(users)):
if users[i]['id'] == str(id):
return int(i)
return -1
def cek_rekening(no):
for i in range(len(users)):
if str(users[i]['no_rekening']) == str(no):
return int(i)
return -1
def tranfer_uang(uang, no_rekening):
index1 = cek_user(user_id)
index2 = cek_rekening(no_rekening)
if index1 >= 0:
if users[index1]['saldo'] >= int(uang):
users[index1]['saldo'] = users[index1]['saldo'] - int(uang)
users[index2]['saldo'] = users[index2]['saldo'] + int(uang)
print("********************************************************")
print("Anda berhasil mentransfer uang Rp." + str(uang) + " ke Rekening " + no_rekening)
print("Sisa saldo anda adalah Rp.", users[index1]['saldo'])
print("********************************************************")
else:
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
print("Ooops saldo anda tidak cukup")
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
def ambil_uang(uang):
index1 = cek_user(user_id)
if index1 >= 0:
if users[index1]['saldo'] >= int(uang):
users[index1]['saldo'] = users[index1]['saldo'] - int(uang)
print("********************************************************")
print("Anda berhasil menarik uang Rp." + str(uang))
print("Sisa saldo anda adalah Rp.", users[index1]['saldo'])
print("********************************************************")
else:
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
print("Ooops saldo anda tidak cukup")
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
while pakai_atm == "y":
while not status_login:
print("<><><><><><><><><><><><><><><><><><><")
print("-------------------------------------")
print("SELAMAT DATANG DI ATM BANK KUPRAKAPRA")
print("-------------------------------------")
print("<><><><><><><><><><><><><><><><><><><")
pin = input("Silahkan masukan PIN : ")
cl = cek_login(pin)
if cl:
print("=====================================")
print("Selamat Datang " + cl['username'])
user_id = cl['id']
status_login = True
loop = "y"
else:
print("!!!!!!!!!!!!!!!!!!!!")
print("Ooops PIN anda salah")
print("!!!!!!!!!!!!!!!!!!!!")
print("")
while loop == "y" and status_login:
u = users[cek_user(user_id)]
print("|<><><><><><><><><><><><><><><><><><><|")
print("|-------------------------------------|")
print("|SELAMAT DATANG DI ATM BANK KUPRAKAPRA|")
print("|-------------------------------------|")
print("|<><><><><><><><><><><><><><><><><><><|")
print("| 1.Cek Saldo |")
print("| 2.Transfer Uang |")
print("| 3.Ambil Uang |")
print("| 4.Logout |")
print("| 5.Keluar ATM |")
print("|-------------------------------------|")
a = int(input("Silahkan pilih menu : "))
if a == 1:
print("------------------------------------")
print("Sisa Saldo anda adalah Rp.", u['saldo'])
print("------------------------------------")
print("")
loop = "n"
elif a == 2:
print("----------------------------------------------------------")
print("Untuk Mentransfer Uang Silahkan Masukan No Rekening Tujuan")
print("----------------------------------------------------------")
no_rek = input("Masukan No Rekening Tujuan : ")
cnk = cek_rekening(no_rek)
if cnk >= 0:
print("Nomor rekening ditemukan,silahkan masukan nominal yang yang akan di transfer")
nominal = input("Nominal Yang Akan Di Transfer : ")
tranfer_uang(nominal, no_rek)
print("")
loop = "n"
else:
print("")
print("Nomor Rekening Tujuan Tidak ditemukan atau tidak terdaftar")
print("")
loop = "n"
elif a == 3:
nominal = input("Nominal Yang Akan Di Tarik : ")
ambil_uang(nominal)
print("")
loop = "n"
elif a == 4:
status_login = False
elif a == 5:
status_login = False
loop = "n"
pakai_atm = "n"
else:
print("Pilihan tidak tersedia")
if status_login == True:
input("kembali Ke menu (y/n) ")
print("")
loop = "y"
No comments:
Post a Comment