Question

In: Computer Science

Write a Python class definition called CellPhone to represent a monthly cell phone bill. The bill...

Write a Python class definition called CellPhone to represent a monthly cell phone bill.

The bill should contain the following information:

  • customer name (default value is the empty string)
  • account number (default value is 0)
  • number of gigabytes (GB) used over the monthly limit (default value is 0)

Include the following methods:

  • a constructor which given a customer name, account number, and number of GB used in excess of the monthly limit, creates a CellPhone object (be sure to account for the default values).
  • an accessor method for the account number
  • a mutator method for the customer name
  • a method that computes and returns the monthly charge calculated as follows:
    • a basic charge of $75
    • if the number of GB used over the monthly limit is 50GB or less then a surcharge of $20 applies
    • if the number of GB used over the monthly limit exceeds 50GB, then the basic surcharge of $20 applies, and each GB over 50 is charged at $2 per GB.
    • 15% tax is added

Solutions

Expert Solution

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:


Related Solutions

The phone company calculates a customer’s monthly cell phone bill as follows: monthly service charge: $35...
The phone company calculates a customer’s monthly cell phone bill as follows: monthly service charge: $35 voice charges: First 100 minutes: $0.018 per minute Second 100 minutes: $0.034 per minute Additional minutes: $0.055 per minute a. What is the charge for a month in which 158 minutes were used? b. What is the charge for a month in which 311 minutes were used? c. Construct a piecewise function that gives the monthly charge for x minutes of usage.
According to CTIA-The Wireless Association, the mean monthly cell phone bill in 2018 was $60.64. A...
According to CTIA-The Wireless Association, the mean monthly cell phone bill in 2018 was $60.64. A market researcher believes that the mean monthly cell phone bill has increased today. a) What would be the null and alternative hypothesis for testing whether the mean monthly cell phone bill today has increased since 2018? b) Calculate the P-Value if the researcher phones a random sample of 40 cell phone subscribers and gets a sample average of $67.45 with a sample standard deviation...
A cell phone company states that the mean cell phone bill of all their customers is...
A cell phone company states that the mean cell phone bill of all their customers is less than $83. A sample of 19 customers gives a sample mean bill of $82.17 and a sample standard deviation of $2.37. At ? = 0.05 , test the company’s claim? 1). State the hypothesis and label which represents the claim: : H 0 : H a 2). Specify the level of significance  = 3). Sketch the appropriate distribution, find and label the...
Java Write a class called Triangle that can be used to represent a triangle. Write a...
Java Write a class called Triangle that can be used to represent a triangle. Write a class called Describe that will interface with the Triangle class The Server • A Triangle will have 3 sides. It will be able to keep track of the number of Triangle objects created. It will also hold the total of the perimeters of all the Triangle objects created. • It will allow a client to create a Triangle, passing in integer values for the...
In C: Write a function definition called PhoneType that takes one character argument/parameter called phone and...
In C: Write a function definition called PhoneType that takes one character argument/parameter called phone and returns a double. When the variable argument phone contains the character a or A print the word Apple and return 1099.99 When phone contains anything else return a 0.0
The assignment is to write a class called data. A Date object is intented to represent...
The assignment is to write a class called data. A Date object is intented to represent a particuar date's month, day and year. It should be represented as an int. -- write a method called earlier_date. The method should return True or False, depending on whether or not one date is earlier than another. Keep in mind that a method is called using the "dot" syntax. Therefore, assuming that d1 and d2 are Date objects, a valid method called to...
Write a Python class to represent a LibraryMember that takes books from a library. A member...
Write a Python class to represent a LibraryMember that takes books from a library. A member has four private attributes, a name, an id, a fine amount, and the number of books borrowed. Your program should have two functions to add to the number of books and reduce the number of books with a member. Both functions, to add and return books, must return the final number of books in hand. Your program should print an error message whenever the...
Write Python class that takes a string and returns with a valid phone number. Number format...
Write Python class that takes a string and returns with a valid phone number. Number format is ten-digit numbers consisting of a three-digit area code and a seven-digit number. Clean up different telephone numbers by removing punctuation, and removing incorrect format and the country code (1). You should throw a ValueError with a string if there are too many or too few digits, or the wrong digits. For example, the strings: +1 (617) 111-0000, 617-111-0000, 1 617 111 0000, 617.111.0000...
Suppose that for a specic model of cell phone, the life-length of a fully-charged cellphone battery...
Suppose that for a specic model of cell phone, the life-length of a fully-charged cellphone battery is normally distributed with a mean of 1200 minutes and a standard deviation of 160 minutes. (a) A person charges his/her cellphone at night and uses it during the day for about 16 hours. What is the probability that he/she does not have to charge his/her cell phone during the day? (b) 80% of fully-charged cell-phone batteries have a life-length more than how many...
You have joined a major cell phone manufacturer. The weight of a cellphone is very important....
You have joined a major cell phone manufacturer. The weight of a cellphone is very important. A light or heavy phone may indicate a future problem. Much of the weight is in the battery. You have gathered the weight of eight phones and want to place in a control chart. The chart should cover the center point and the spread of the weights. 1. What chart would you use – attribute or variable? The following points have been gathered.   Place...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT