























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























COMPUTER SCIENCE PROJECT ON TELEPHONE BILLING SYSTEM
PYTHON PROGRAMMING LANGUAGE
CLASSES
FUNCTIONS
class customer: cno='' ph='' name='' addr='' city='' def getdata(self): import os os.system('cls') print("\n"4) self.ph=int(input("\n\t\t\tEnter The 8 Digit Telephone No. :")) self.cno=int(input("\n\t\t\tEnter The Consumer No:")) self.name=input("\n\t\t\tEnter Name:") self.city=input("\n\t\t\tEnter City:") self.addr=input("\n\t\t\tEnter Address:") self.type=input('''\n\t\t\tEnter 'O' for Office Or 'Enter' for residential:''') if self.type.upper()=='O': self.type='Office' else: self.type='Home ' def showdata(self): import os os.system('cls') print("\n"4)
print("\t\t\tPhone No:",self.ph) print("\t\t\tConsumer No:",self.cno) print("\t\t\tName:",self.name) print("\t\t\tCity:",self.city) print("\t\t\tAddress:",self.addr) print("\t\t\tType:",self.type) def showcust(self): print("\t\t",self.ph,"\t",self.cno,"\t",self.type," ",self.name) #====================================================== #CLASS TO CALCULATE AND DISPLAY THE BILL #======================================================= class bill: def init(self): customer.init(self) self.ffcalls= self.oprd='' self.clrd='' self.mcalls= self.fcalls= self.credit='' self.debits='' self.chargec= self.chargem= self.tax= self.grossamt= self.surcharge=
except EOFError: pass if self.found==False: print("\n\t\t\tTelephone Number Not Found In The Records") input("\n\t\t\tPress Any Key To Continue") return self.file.close() self.ffcalls= while self.oprd=='': self.oprd=input("\n\t\t\tEnter The Open Meter Reading:") while self.clrd=='': self.clrd=input("\n\t\t\tEnter The Close Meter Readng:") self.oprd=int(self.oprd) self.clrd=int(self.clrd) self.mcalls=self.clrd-self.oprd if self.mcalls while self.credit=='': self.credit=input("\n\t\t\tEnter Credits If Any:") self.credit=int(self.credit) if self.credit>self.grossamt: self.netamtbef= self.surcharge= else: self.netamtbef=self.grossamt-self.credit self.netamtaft=self.netamtbef+self.surcharge #=======================================================
#======================================================= def dispbill(self): import os os.system('cls') print("\n"4) if self.found: print("\n") print("="31,"Telephone Bill","="32) print("Name:",self.c.name) print("-"79) print("Address:",self.c.addr) print("="79) print("Telephone Number",end=' '3)
def addrec(): import pickle file=open("bill.dat",'ab') c=customer() import os while True: os.system('cls') print("\n"*4) c.getdata() pickle.dump(c,file) ch=input("\n\t\t\tDo You Want To Enter More Records:") if ch.upper()=='N': break file.close() #=======================================================
#======================================================= def showrec(): import pickle file=open('bill.dat','rb') c=customer() import os os.system('cls') print("\n"*4)
print("\t\tPhone No.\t Consumer No.\t Type\t Name") try: while True: c=pickle.load(file) print('\n') c.showcust() except EOFError: pass file.close() input("\n\t\t\tPress Any Key To Continue") def searchrec(): import pickle file=open("bill.dat","rb") c=customer() import os os.system('cls') print("\n"*4) phn=int(input("\n\t\t\tEnter The Telephone No. :")) found=False try: while True: c=pickle.load(file) if phn==c.ph: found=True break except EOFError:
c.showdata() input("\n\t\t\tPress any key to continue") pass elif c.ph!=phone: pickle.dump(c,temp) except EOFError: pass file.close() temp.close() os.remove('bill.dat') os.rename('temp.dat','bill.dat') #=======================================================
#======================================================= def modrec(): import pickle file = open("bill.dat", 'rb') clist = list() i = 0 c = customer() import os os.system('cls') print("\n"*4) phn = int(input("\n\t\t\tEnter The Telephone Number : ")) try: while True :
c = pickle.load(file) clist.append(c); except EOFError : pass file.close() found = False i = 0 for c in clist : if ( c.ph==phn ) : found = True break else : i = i+ if ( not found ) : print("\n\t\t\tInvalid Phone Number ") return import os os.system('cls') print("\n"*4) print("\n\t\t\tEnter The New Details About The Customer:") clist[i].getdata() file = open("bill.dat", 'wb') for c in clist : pickle.dump(c,file) file.close()
opt= while opt!=4: menu() opt=int(input("\n\t\t\tEnter Your Choice:")) if opt==1: b=bill() b.calbill() b.dispbill() elif opt==2: showrec() elif opt==3: ropt= while ropt!=4: menurec() ropt=int(input("\n\t\t\tEnter Your Choice:")) if ropt==1: showrec() elif ropt==2: addrec() elif ropt==3: searchrec() elif ropt==4: delrec()
elif ropt==5: modrec() elif ropt==6: break else: print("\n\t\t\tInvalid Choice") input("\n\t\t\tPress Any Key To Continue") elif opt==4: print("\n\t\t\tGood Bye") input("\n\t\t\tPress Any Key To Continue") break else: print("\n\t\t\tInvalid Choice") input("\n\t\t\tPress Any Key To Continue")