In: Computer Science
Write a Python class definition called CellPhone to represent a monthly cell phone bill.
The bill should contain the following information:
Include the following methods:
The answer to this question is as follows:
The code is as follows:
class CellPhone:
def __init__(self, customer_name="",
account_number=0,num_gb=0):
self.customer_name=customer_name
self.account_number=account_number
self.num_gb=num_gb
def getCustomerName(self):
return self.customer_name
def getAccountNumber(self):
return self.account_number
def getNumberOfGb(self):
return self.num_gb
def setCustomerName(self,customer_name):
self.customer_name=customer_name
def setAccountNumber(self,account_number):
self.account_number=account_number
def setNumberOfGb(self,num_gb):
self.num_gb=num_gb
def monthlyCharge(self):
if(self.num_gb<=50 and self.num_gb>0):
return 75+20
elif(self.num_gb>50):
amount=(75+20+(self.num_gb-50)*2)
tax_amount=amount*0.15
return amount+tax_amount
c1=CellPhone("max",123456,50)
print("The bill details is as follows")
print("The customer name: ",c1.getCustomerName())
print("The account number is :",c1.getAccountNumber())
print("The number of gb used is: ",c1.getNumberOfGb())
print("The monthly charge for the usage is
",c1.monthlyCharge())
The input and output are provided in the screenshot below: