CS Main
CS Main
PA
GE NO.
System Requirement
1
Source Code
3
Output Screenshot
10
Bibliography
13
SYSTEM REQUIREMENTS
Ram - 2 GB
This program :
Adds new record
Booking record
Calculate room rent
Calculate restraunt bill
Calculate game bill
Displays all records
Search for a record
Update a record
Modules used :
pickle
os
Functions used :
Dump
Load
User defined functions
Page No -2
SOURCE CODE
import pickle
import os
def new():
c=0
cid=0
if os.path.isfile("Hotel.dat"):
f=open("Hotel.dat", 'rb')
try:
while True:
rec=pickle.load(f)
c+=1
except:
f.close()
nm=input("\nEnter Customer Name: ")
ad=input("Enter Customer Address: ")
ag=int(input("Enter Customer Age: "))
cn=input("Enter Customer Country: ")
no=int(input("Enter Customer Phone Number: "))
em=input("Enter Customer Email:")
cid=c+101
print("Your customer ID is: ",cid)
print()
print(" NEW CUSTOMER ENTERED IN THE SYSTEM SUCESSFULLY!! \n")
rec=[cid,nm,ad,ag,cn,no,em]
f=open("Hotel.dat","ab")
pickle.dump(rec,f)
f.close()
def book():
Page No -3
ci=input("\nEnter Customer Check-In Date [YYYY-MM-DD]: ")
od=input("Enter Customer Check-Out Date [YYYY-MM-DD]: ")
print()
print(" CHECK-IN AND CHECK-OUT ENTRY MADE SUCESSFULLY!! \n")
def room():
print("\n\t WE HAVE FOLLOWING ROOMS FOR YOU ")
print("\t")
print("1. Ultra Royal Rs. 8500")
print("2. Royal Rs. 6500")
print("3. Elite Rs. 4500")
print("4. Budget Rs. 3000 \n")
ch=int(input("\t Enter Your choice --> "))
da=int(input("\t Enter Number of days: "))
if ch==1:
print("\n\t Ultra Royal Room rent: 8500")
print("\t Your Total Room Rent is Rs. ", 8500*da)
elif ch==2:
print("\n\t Royal Room rent: 6500")
print("\t Your Total Room Rent is Rs. ", 6500*da)
elif ch==3:
print("\n\t Elite Room rent: 4500")
print("\t Your Total Room Rent is Rs. ", 4500*da)
elif ch==4:
print("\n\t Budget Room rent: 3000")
print("\t Your Total Room Rent is Rs. ", 3000*da)
print()
print("________________________________________________________________")
print()
print("THANK YOU!!! YOUR ROOM HAS BEEN BOOKED FOR", da, 'DAYS!')
print("ENJOY YOUR STAY !!")
print("________________________________________________________________\n")
Page No -4
def FoodMenu():
print("\n\tWE HAVE FOLLOWING FOOD OPTIONS :")
print("\t")
print("1. Vegetarian Combo Rs. 300")
print("2. Non Vegetarian Rs. 500")
print("3. Mix Veg and Non Veg Rs. 750")
cu=int(input("\n\tEnter Cuisine Number: "))
qn=int(input("\tEnter Quantity: "))
print("______________________________________________________________________\n")
if cu==1:
pr=300
print("\t50 YOU HAVE ORDERED VEGETARIAN COMBO")
if cu==2:
pr=500
print("\tSO YOU HAVE ORDERED NON-VEGETARIAN COMBO")
if cu==3:
pr=750
print("\tSO YOU HAVE ORDERED VEGETARIAN AND NON-VEGETARIAN COMBO \n")
tt=qn*pr
print("\tYOUR TOTAL BILL AMOUNT IS Rs. ",tt, )
print ("\tENJOY YOUR MEAL !!! \n")
print("______________________________________________________________________")
def game():
print("\n\t WE HAVE FOLLOWING GAMES OPTIONS :\n")
print("1. Table Tennish Rs. 150/hr")
print("2. Bowling Rs. 100/hr ")
print("3. Swimming Pool Games Rs. 350/hr")
print("4. Video Games Rs. 300/hr")
print("5. Snooker Rs. 250/hr")
wg=int(input("\n\tEnter Your Game Choice: "))
tm=int(input("\tEnter No. Of Hours You Want To Play: "))
Page No -5
print("________________________________________________________\n")
if wg==1:
pr=150
print("\tYOU HAVE DECIDED TO PLAY Table Tennis")
elif wg==2:
pr=100
print("\tYOU HAVE DECIDED TO PLAY: Bowling")
elif wg==3:
pr=350
print("\tYOU HAVE DECIDED TO PLAY: Suwiming Pool Games")
elif wg==4:
pr=300
print("\tYOU HAVE DECIDED TO PLAY Video Games")
elif wg==5:
pr=250
print("\tYOU HAVE DECIDED TO PLAY: Snooker")
tt=pr*tm
print("\n YOUR TOTAL GAMING BILL IS: Rs.", tt, "FOR", tm,'HOURS!')
print("\tWE HOPE YOU WILL ENJOY YOUR GAME!!")
print("________________________________________________________\n")
def details():
if os.path.isfile("Hotel.dat"):
f=open("Hotel.dat","rb")
print("--------------------------------------------------------------------------------------------------------------")
print(": Id : Name : Address : Age : Country : Phone No. : Email :")
print("--------------------------------------------------------------------------------------------------------------")
try:
flag=0
while True:
rec=pickle.load(f)
print(":",rec[0]," "*(3-len(str(rec[0]))),": ",rec[1]," "*(9-len(rec[1])),": ",rec[2],
Page No -6
" "*(12-len(rec[2])),": ",rec[3]," "*(2-len(str(rec[3]))),": ",rec[4],
" "*(8-len(rec[4])),": ",rec[5]," "*(12-len(str(rec[5]))),":",rec[6]," "*(20-len(rec[6])),":")
flag=1
except EOFError:
if flag==0:
print(" No Records!!")
f.close()
print("\n")
def search():
n=int(input("Enter Customer ID : "))
if os.path.isfile("Hotel.dat"):
f=open("Hotel.dat", "rb")
try:
flag=0
while True:
rec=pickle.load(f)
if rec[0]==n:
print("---------------------------------------------------------------------------------------------------------")
print(": Id : Name : Address : Age : Country : Phone No. : Email :")
print("---------------------------------------------------------------------------------------------------------")
print(":",rec[0]," "*(3-len(str(rec[0]))),": ",rec[1]," "*(9-len(rec[1])),": ",rec[2],
" "*(12- len(rec[2])),": ",rec[3]," "*(2-len(str(rec[3]))),": ",rec[4]," "*(8-len(rec[4])),
": ",rec[5]," "*(12-len(str(rec[5]))),":",rec[6]," "*(20-len(rec[6])),":")
flag=1
except:
if flag==0:
print(" Record not found !! ")
finally:
f.close()
print()
def update():
Page No -7
if os.path.isfile("Hotel.dat"):
n=int(input("Enter Customer ID : "))
f=open("Hotel.dat", "rb+")
try:
found=0
while True:
a=f.tell()
rec=pickle.load(f)
if rec[0]==n:
found=1
print("Record Found Successfully!! \n")
newnm=input("Enter New Name : ")
newad=input("Enter New Address : ")
newag=input("Enter New Age : ")
newcn=input("Enter New Country : ")
newno=input("Enter New Phone No. : ")
newem=input("Enter New Email : ")
f.seek(a)
newdata=[n,newnm,newad,newag,newcn,newno,newem]
pickle.dump(newdata,f)
print("\n Record Updated Successfully!! \n")
except:
if found==0:
print(" No Record Found!! ")
finally:
f.close()
while True:
print("\t--------------------------------------------\t")
print("\t\t HOTEL MANAGMENT SYSTEM")
print("\t--------------------------------------------\t")
print("\t 1. Enter Customer Detail \n \t 2. Booking Record")
Page No -8
print("\t 3. Calculate Room Rent \n \t 4. Calulate Resturant Bill ")
print("\t 5. Calculate Game Bill \n \t 6. Display Customer Details ")
print("\t 7. Search Record ")
print("\t 8. Update Record \n \t 9. Exit ")
n=int(input("\n Enter Your Option: "))
if n==1:
new()
elif n==2:
book()
elif n==3:
room()
elif n==4:
FoodMenu()
elif n==5:
game()
elif n==6:
details()
elif n==7:
search()
elif n==8:
update()
elif n==9:
exit(None)
else:
print("Wrong Choice")
Page No -9
BIBLIOGRAPHY
https://www.cs2study.com