June is Combung
ATM[4단계] : 전체 기능구현 본문
# ATM[4단계] : 전체 기능구현
# 1. 회원가입
# . id와 pw를 입력받아 가입
# . 가입 시 돈 1000원 부여
# . id 중복체크
# 2. 회원탈퇴
# . 로그인시에만 이용가능
# 3. 로그인
# . id와 pw를 입력받아 로그인
# . 로그아웃 상태에서만 이용가능
# 4. 로그아웃
# . 로그인시에만 이용가능
# 5. 입금
# . 로그인시에만 이용가능
# 6. 이체
# . 로그인시에만 이용가능
# 7. 잔액조회
# . 로그인시에만 이용가능
size = 5
ids = [0 for i in range(size)]
pws = [0 for i in range(size)]
moneys = [0 for i in range(size)]
count = 0
log = -1
while True:
print("=== 메가IT ATM ===")
print("[1]회원가입")
print("[2]회원탈퇴")
print("[3]로그인")
print("[4]로그아웃")
print("[5]입금")
print("[6]이체")
print("[7]잔액조회")
print("[0]종료")
choice = int(input("메뉴 선택 : "))
if choice == 1:
idx = 0
while True:
if ids[idx] == 0:
break
idx += 1
my_id = int(input("사용할 id: "))
check = 0
for i in range(size):
if my_id == ids[i]:
print("중복입니다.")
check = 1
break
if check == 0:
ids[idx] = my_id
my_pw = int(input("사용할 pw: "))
pws[idx] = my_pw
print("회원가입 완료. 가입 기념으로 1000원 충전")
moneys[idx] = 1000
else:
continue
elif choice == 2:
if log == -1:
print("로그인 후 이용해주십시오")
continue
ids[log] = 0
pws[log] = 0
log = -1
print("탈퇴되었습니다.")
elif choice == 3:
if log == -1:
my_id = int(input("id: "))
my_pw = int(input("pw: "))
for i in range(size):
if my_id == ids[i] and my_pw == pws[i]:
log = i
print("%d님, 로그인 되었습니다."%(ids[i]))
break
if log == -1:
print("아이디 혹은 패스워드 오류입니다.")
else:
print("이미 로그인 되어있습니다.")
elif choice == 4:
if log == -1:
print("이미 로그아웃 되어있습니다.")
else:
log = -1
print("로그아웃 되었습니다.")
elif choice == 5:
if log == -1:
print("로그인 후 이용해주십시오")
continue
m = int(input("입금할 금액을 입력하세요: "))
moneys[log] += m
print("입금 완료")
elif choice == 6:
if log == -1:
print("로그인 후 이용해주십시오")
continue
m = int(input("이체할 금액을 입력하세요: "))
if moneys[log] >= m:
moneys[log] -= m
print("이체 완료")
else:
print("잔액이 부족합니다.")
elif choice == 7:
if log == -1:
print("로그인 후 이용해주십시오")
continue
print("잔액은 %d원 입니다."%(moneys[log]))
elif choice == 0:
print("프로그램 종료")
break
'python > 리스트' 카테고리의 다른 글
석차 출력 (0) | 2021.03.01 |
---|---|
정렬하기 (0) | 2021.03.01 |
1 to 50[3단계] (0) | 2021.02.28 |
숫자 야구 게임 (0) | 2021.02.28 |
중복숫자 금지[2단계] (0) | 2021.02.28 |
Comments