"Menghitung Suhu, Mata Uang dan Panjang"
def clear ():
import os
os.system('cls')
def suhu():
def daftar():
print ("")
print ("")
print ("\tProgram Konversi Suhu")
print ("\n=================================================")
print ("")
print ("\nPilihan :")
for suhu in ["1. Celsius","2. Reamur","3. Fahrenheit","4. Kembali ke Menu Utama","5. Exit"]:
print suhu
print ("")
class konversi():
def Celsius(self,z):
print z,'Reamur','=',z*0.8,'R'
print z,'Fahrenheit','=',(z*1.8)+32,'F'
def Reamur(self,z):
print z,'Celsius','=',z*1.25,'C'
print z,'Fahrenheit','=',(z*2.25)+32,'F'
def Fahrenheit(self,z):
print z,'Celsius','=',(z*0.555)-32,'C'
print z,'Reamur','=',(z*0.444)-32,'R'
def back_menu():
print ('Apakah anda ingin mencoba lagi? [Y/N] :')
back = raw_input().upper()
if back == "Y":
try:
clear()
daftar()
pilihan()
except:
print "Anda memasukan bukan Angka!!"
back_menu()
elif back == "N":
exit
else:
print "Pilih Y [untuk mencoba lagi], Pilih N [exit]"
back_menu()
def pilihan():
x = input ("Masukan Pilihan : ")
if x == 1:
z = input ('Masukan besar suhu Celsius: ')
hasil = konversi()
hasil.Celsius(z)
print ("\n=================================================")
print ("")
back_menu()
elif x == 2:
z = input ('Masukan besar suhu Reamur: ')
hasil = konversi()
hasil.Reamur(z)
print ("\n=================================================")
print ("")
back_menu()
elif x == 3:
z = input ('Masukan besar suhu Fahrenheit: ')
hasil = konversi()
hasil.Fahrenheit(z)
print("\n=================================================")
print ("")
back_menu()
elif x==4:
clear()
back_utama()
elif x==5:
exit
else:
print "Anda memasukan yang tidak ada didalam pilihan!!"
print ("")
back_menu()
try:
daftar()
pilihan()
except:
print "Anda memasukan bukan Angka!!"
back_menu()
def KonversiUang():
def daftar2():
print ("")
print ("")
print ("\tProgram Konversi Mata Uang")
print ("\n=================================================")
print ("")
print ("\nPilihan :")
for MataUang in ["1. Rupiah","2. Dollar US","3. Euro","4. Yen","5. Kembali ke Menu Utama","6. Exit"]:
print MataUang
print ("")
class kurs():
def Rp(self,k):
print k,'IDR','=',k*0.000083,'EUR'
print k,'IDR','=',k*0.00011,'USD'
print k,'IDR','=',k*0.012,'JPY'
def USD (self,k):
print k,'USD','=',k*0.7566,'EUR'
print k,'USD','=',k*9107.47,'IDR'
print k,'USD','=',k*118.36,'JPY'
def EUR (self,k):
print k,'EUR','=',k*12037,'IDR'
print k,'EUR','=',k*156.44,'JPY'
print k,'EUR','=',k*1.32,'USD'
def JPY (self,k):
print k,'JPY','=',k*0.006,'EUR'
print k,'JPY','=',k*0.008,'USD'
print k,'JPY','=',k*76.94,'IDR'
def back_menu2():
print ('Apakah anda ingin mencoba lagi? [Y/N] :')
back = raw_input().upper()
if back == "Y":
try:
clear()
daftar2()
pilihan2()
except:
print "Anda memasukan bukan Angka!!"
back_menu2()
elif back == "N":
exit
else:
print "Pilih Y [untuk mencoba lagi], Pilih N [exit]"
print ("")
back_menu2()
def pilihan2():
p = input ("Masukan Pilihan : ")
if p == 1:
k = input ('Masukan nilai Rupiah : ')
hasil = kurs()
hasil.Rp(k)
print ("\n=================================================")
print ("")
back_menu2()
elif p == 2:
k = input ('Masukan nilai Dollar : ')
hasil = kurs()
hasil.USD(k)
print ("\n=================================================")
print ("")
back_menu2()
elif p == 3:
k = input ('Masukan nilai Euro : ')
hasil = kurs()
hasil.EUR(k)
print ("\n=================================================")
print ("")
back_menu2()
elif p==4:
k = input ('Masukan nilai Yen : ')
hasil = kurs()
hasil.JPY (k)
print ("\n=================================================")
print ("")
back_menu2()
elif p==5:
clear()
back_utama()
elif p==6:
exit
else:
print "Anda memasukan yang tidak ada didalam pilihan!!"
print ("")
back_menu2()
try:
daftar2()
pilihan2()
except:
print "Anda memasukan bukan Angka!!"
back_menu2()
def KonversiPanjang():
def daftar3():
print ('')
print ('')
print ('\t\tProgram Konversi Jarak')
print ('\n========================================================')
print ('')
print ('\nPilihan :')
for panjang in ('1. Centimeter','2. Meter','3. Kaki','4. Inci','5. Mil','6. Kembali ke Menu Utama','7. Exit'):
print panjang
print ('')
class panjang():
def cm(self,s):
print s*0.01,'meter'
print s*0.032808,'kaki'
print s*0.393701,'inci'
print s*393.7007,'mil'
def m(self,s):
print s*100,'centimeter'
print s*3.28084,'kaki'
print s*39.37007,'inci'
print s*39370.07,'mil'
def ft(self,s):
print s*0.3048,'meter'
print s*30.48,'centimeter'
print s*12,'inci'
print s*0.000189,'mil'
def inci(self,s):
print s*0.0254,'meter'
print s*2.54,'sentimeter'
print s*0.08333,'kaki'
print s*1000,'mil'
def mil(self,s):
print s*0.000025,'meter'
print s*0.00254,'centimeter'
print s*0.000083,'kaki'
print s*63360,'inci'
def back_menu3():
print ('Apakah anda ingin mencoba lagi? [Y/N] :')
back = raw_input().upper()
if back == "Y":
try:
clear()
daftar3()
pilihan3()
except:
print "Anda memasukan bukan angka!!"
back_menu3()
elif back=="N":
exit
else:
print "Pilih Y [untuk mencoba lagi], Pilih N [exit]"
print ('')
back_menu3()
def pilihan3():
p = input ("Masukan Pilihan : ")
if p == 1:
s = input('Masukan jarak (cm) : ')
hasil = panjang()
hasil.cm(s)
print ("\n=================================================")
print ("")
back_menu3()
elif p == 2:
s = input('Masukan jarak (m) : ')
hasil = panjang()
hasil.m(s)
print ("\n=================================================")
print ("")
back_menu3()
elif p == 3:
s = input('Masukan jarak (kaki) : ')
hasil = panjang()
hasil.ft(s)
print("\n=================================================")
print ("")
back_menu3()
elif p == 4:
s = input('Masukan jarak (inci) : ')
hasil = panjang()
hasil.inci(s)
print("\n=================================================")
print ("")
back_menu3()
elif p == 5:
s = input('Masukan jarak (mil) : ')
hasil = panjang()
hasil.mil(s)
print("\n=================================================")
print ("")
back_menu3()
elif p == 6:
clear()
back_utama()
elif p==7:
exit
else:
print "Anda memasukan yang tidak ada didalam pilihan!!"
print ("")
back_menu3()
try:
daftar3()
pilihan3()
except:
print "Anda memasukan bukan angka!!"
back_menu3()
def daftar_utama():
print ("")
print ("")
print ("\tProgram Konversi")
print ("\n=================================================")
print ("")
print ("\nPilihan :")
for Menu_Utama in ["1. Suhu","2. Mata Uang","3. Jarak","4. Exit"]:
print Menu_Utama
print ("")
def back_utama():
print ('Apakah anda ingin ke Menu Utama? [Y/N] :')
back2= raw_input().upper()
if back2=="Y":
try:
clear()
daftar_utama()
pilihan_utama()
except:
clear()
print "Anda memasukan bukan Angka!!"
back_utama()
elif back2=="N":
exit
else:
print "Pilih Y [untuk mencoba lagi], Pilih N [exit]"
back_utama()
def pilihan_utama():
q=input ("Masukan Pilihan : ")
if q==1:
suhu()
elif q==2:
KonversiUang()
elif q==3:
KonversiPanjang()
elif q==4:
exit
else:
clear()
print "Anda memasukan yang tidak ada dalam pilihan!!!"
print ""
back_utama()
try:
daftar_utama()
pilihan_utama()
except:
print "Anda memasukan bukan Angka!!"
back_utama()