Program Python Daftar Menu
Menggunakan Python Versi 3.7.2
-------------------------------------------
class TOKO_ABC:
def __init__(self, harga=0):
self.harga = harga
def menu(self):
print ("Toko ABC Galaxy")
print ("--" * 20)
print ("1. Doll Toys Rp. 250.000,-")
print ("2. Car Toys Rp. 150.000,-")
print ("3. Ball Toys Rp. 50.000,-")
print ("4. Keluar")
print ("--" * 20)
print ("")
def DT(self):
qty = int(input("Masukkan Quantity : "))
self.harga += (qty * 250000)
def CT(self):
qty = int(input("Masukkan Quantity : "))
self.harga += (qty* 150000)
def BT(self):
qty = int(input("Masukkan Quantity : "))
self.harga += (qty * 50000)
def bayar(self):
print ("")
print ("--" * 20)
print("Total Harga Belanja : ", "RP. " + str(self.harga))
UP = int(input("Masukkan Uang Pembeli : Rp. "))
KBN = UP - self.harga
print ("--" * 20)
print ("")
print ("--" * 20)
print("Total Harga Belanja : ", "RP. " + str(self.harga))
print("Uang Yang DiTerima : ", "RP. " + str(UP))
print("Uang Kembalian : ", "RP. " + str(KBN))
print("TERIMA KASIH SUDAH BERBELANJA DI TOKO ABC KAMI...")
print ("--" * 20)
program = TOKO_ABC()
program.menu()
ulang = 'y'
while ulang is 'y':
pilih = int(input("Masukkan Pilihan : "))
if pilih == 1:
program.DT()
elif pilih == 2:
program.CT()
elif pilih == 3:
program.BT()
else:
print ("Pilihan Tidak Tersedia")
ulang = input("Masukkan Pilihan Lagi [Y/T] : ")
program.bayar()
OUTPUT
-------------------------------------------
class TOKO_ABC:
def __init__(self, harga=0):
self.harga = harga
def menu(self):
print ("Toko ABC Galaxy")
print ("--" * 20)
print ("1. Doll Toys Rp. 250.000,-")
print ("2. Car Toys Rp. 150.000,-")
print ("3. Ball Toys Rp. 50.000,-")
print ("4. Keluar")
print ("--" * 20)
print ("")
def DT(self):
qty = int(input("Masukkan Quantity : "))
self.harga += (qty * 250000)
def CT(self):
qty = int(input("Masukkan Quantity : "))
self.harga += (qty* 150000)
def BT(self):
qty = int(input("Masukkan Quantity : "))
self.harga += (qty * 50000)
def bayar(self):
print ("")
print ("--" * 20)
print("Total Harga Belanja : ", "RP. " + str(self.harga))
UP = int(input("Masukkan Uang Pembeli : Rp. "))
KBN = UP - self.harga
print ("--" * 20)
print ("")
print ("--" * 20)
print("Total Harga Belanja : ", "RP. " + str(self.harga))
print("Uang Yang DiTerima : ", "RP. " + str(UP))
print("Uang Kembalian : ", "RP. " + str(KBN))
print("TERIMA KASIH SUDAH BERBELANJA DI TOKO ABC KAMI...")
print ("--" * 20)
program = TOKO_ABC()
program.menu()
ulang = 'y'
while ulang is 'y':
pilih = int(input("Masukkan Pilihan : "))
if pilih == 1:
program.DT()
elif pilih == 2:
program.CT()
elif pilih == 3:
program.BT()
else:
print ("Pilihan Tidak Tersedia")
ulang = input("Masukkan Pilihan Lagi [Y/T] : ")
program.bayar()
OUTPUT
Komentar
Posting Komentar