안끝나는 자판기

2025. 2. 24. 19:12·python/연습장
while True: #break 걸기 전까지 영원히 안끝남
    user_money2 = input("돈을 넣어주세요.: ")  # input함수로 반환하면 문자형으로 반환되기때문에
    user_money2 = int(user_money2)  # 숫자형으로 바꿔주는 과정 필요
    user_select2 = input("음료를 골라주세요.: ")

    if user_money2 >= 900 and user_select2 == "코카콜라":
        print("코카콜라")
        user_money2 = user_money2 - 900
    elif user_money2 < 900 and user_select2 == "코카콜라":
        print("돈이 부족합니다.")
    elif user_money2 >= 800 and user_select2 == "펩시콜라":
        print("펩시콜라")
        user_money2 = user_money2 - 800
    elif user_money2 < 800 and user_select2 == "펩시콜라":
        print("돈이 부족합니다.")
    elif user_money2 >= 700 and user_select2 == "포카리":
        print("포카리")
        user_money2 = user_money2 - 700
    elif user_money2 < 700 and user_select2 == "포카리":
        print("돈이 부족합니다.")
    elif user_money2 >= 500 and user_select2 == "물":
        print("물")
        user_money2 = user_money2 - 500
    elif user_money2 < 500 and user_select2 == "물":
        print("돈이 부족합니다.")

    else:  # 돈x메뉴x=메뉴x
        user_select2 != "코카콜라", "펩시콜라", "포카리", "물"
        # user_money2 < 900 and user_select2 != "코카콜라"
        # user_money2 < 800 and user_select2 != "펩시콜라"
        # user_money2 < 700 and user_select2 != "포카리"
        # user_money2 < 500 and user_select2 != "물"
        print("해당 메뉴가 존재하지 않습니다.")
    print(user_money2)






'python > 연습장' 카테고리의 다른 글

로또 구매 프로그램  (2) 2025.02.27
로또 자동 판매기 (no sample)  (0) 2025.02.26
내가 만든 자판기  (1) 2025.02.21
교수님이 만든 자판기  (0) 2025.02.21
가위바위보 게임  (0) 2025.02.21
'python/연습장' 카테고리의 다른 글
  • 로또 구매 프로그램
  • 로또 자동 판매기 (no sample)
  • 내가 만든 자판기
  • 교수님이 만든 자판기
joo_coding
joo_coding
2025.02.18~
  • joo_coding
    주코딩일지
    joo_coding
  • 전체
    오늘
    어제
    • 분류 전체보기 (159)
      • 일지 (19)
      • 계획표 (7)
      • C언어 (35)
        • 연습장 (12)
      • 과제 (2)
      • C++ (3)
      • python (28)
        • 연습장 (11)
      • TCP IP (4)
      • DB (2)
      • ubuntu (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    c언어 #vscode #gcc #윈도우 #c언어윈도우 #gcc윈도우 #vscode윈도우 #c #c++
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
joo_coding
안끝나는 자판기
상단으로

티스토리툴바