Question

Lab 8 python code for Cell Phone Bill

Lab 8: Cell Phone Bill Calculator

Write the Python code for the following programming problem definition.
Use modular design according to the modules specified below.

Design and write a program that calculates and displays the number of minutes over the monthly contract minutes that a cell phone user incurred. The program should askthe user how many minutes were used during the month and how many minutes they were allowed. Validate the input as follows:

• The minimum minutes allowed should be at least 100, but not greater than 700. Validate input so that the minutes allowed are between 100 and 700.
• The minutes used must be over 0. Validate input so that the user does not enter a negative value.

Once correct data is entered, the program should calculate the number of minutes over the minute allowed. If minutes were not over, print a message that they were notover the limit. If minutes were over, for every minute over, a .15 fee should be added to the monthly contract rate of 64.95. Be sure not to add the .15 fee to thenumber of minutes allowed, but rather just minutes over. Display the number of minutes used, minutes allowed, the number of minutes over, and the total due thatmonth.

Use the following functions in your program design:
• A function that allows the user to enter in minutes allowed within the range of 100 and 700.
• A function that allows the user to enter in the minutes used greater than or equal to 0.
• A function that calculates the total due and the total minutes over.
• A function that prints a monthly use report.

Your sample output might look as follows (note the validation code):
0 0
Add a comment Improve this question Transcribed image text
Answer #1
def main():
while(True):
allowed = int(input("How many minutes are allowed: "))
while(not minAllowed(allowed)):
print("Please enter minutes between 100 and 700")
allowed = int(input("How many minutes are allowed: "))
 
used = int(input("How many minutes were used: "))
while(not minUsed(used)):
print("Please enter minutes used of at least 0")
used = int(input("How many minutes were used: "))
 
over = totalOver(allowed,used)
if(over > 0):
print("You were over your minutes by " + str(over))
else:
over = 0
print("You were not over your minutes for the month")
 
printReport(allowed,used,over)
 
toEnd = input("Do you want to end program? (Enter no or yes): ")
toEnd = toEnd.rstrip('\r')
while((toEnd != "yes"and (toEnd != "no")):
print("Please enter a yes or no")
toEnd = input("Do you want to end program? (Enter no or yes): ")
 
if(toEnd == "yes"):
break
 
def printReport(allowed,used,over):
print("---------------MONTHLY USE REPORT------------------")
print("Minutes allowed were " + str(allowed))
print("Minutes used were " + str(used))
print("Minutes over were " + str(over))
print("Total due is $ " + str(totalDue(over)))
 
def minAllowed(min):
if(min >= 100and (min <= 700):
return True
else:
return False
 
def minUsed(min):
if(min >= 0):
return True
else:
return False
 
def totalOver(allowed,used):
return (used - allowed)
 
def totalDue(over):
return (64.95 + (0.15*over))
answered by: codegates
Add a comment
Know the answer?
Add Answer to:
Lab 8 python code for Cell Phone Bill
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Programming Problem description with its major requirements labeled from A to I. A mobile phone...

    Java Programming Problem description with its major requirements labeled from A to I. A mobile phone service provider has three different subscription packages for its customers: Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99 per month unlimited minutes are provided. Design a class MobileCharges that calculates a customer’s monthly bill. It should...

  • PLEASE DO THIS IN JAVA!Design (pseudocode) and implement (source code) a program (name it PhoneBill) that...

    PLEASE DO THIS IN JAVA!Design (pseudocode) and implement (source code) a program (name it PhoneBill) that calculates the bill for a cellular telephone company. The company offers two types of service: regular service and premium service. The rates vary depending on the type of service. The rates are computed as follows: Regular service: $15.00 fee covering first 50 minutes. Charges for over 50 minutes are computed at the rate of $0.50 per minute. Premium service: $25.00 fee plus: a. For...

  • Write a program **(IN C)** that displays all the phone numbers in a file that match the area code...

    Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...

  • Design an algorithm for each of the exercises and type it into a word document. Upload...

    Design an algorithm for each of the exercises and type it into a word document. Upload the document to PE1 assignment folder. 1) Decision-based Algorithm: A cell phone company offers a plan with 750 minutes of voice communications at a rate of $40.00/month. Any minutes over 750 are charged at a rate of 0.50 per minute. Write an algorithm that allows the user to input the number of minutes a phone customer used during a particular month. The algorithm should...

  • write in C++ Problem 1: Mobile Service Provider A cell phone service provider has three different...

    write in C++ Problem 1: Mobile Service Provider A cell phone service provider has three different subscription packages for its customers. Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99 per month unlimited minutes provided. Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased...

  • Chapter 7 exercise 4, python code for Speeding violation Cal

    Exercise 4 – Chapter 7 Speeding violation CalculatorPython code for the followingDesign a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speedlimit and the driver’s speed. Validate the input as follows:• The speed limit should be at least 20, but not greater than 70.• The driver’s speed should be at least the value entered for the speed limit (otherwise the driver...

  • Q2.1) Write a program to calculate phone bill of the user. The rule to calculate bill...

    Q2.1) Write a program to calculate phone bill of the user. The rule to calculate bill is given as follows: • You should ask the option to the user at first. If the phone bill will be calculated with internet connection option, user must enter 1, otherwise user must enter O. Do all necessary controls and take the number from the user until the user enters one of the correct options. (1 or 0). • Design 2 different methods. Both...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • A friend of yours is considering two cell phone service providers. Provider A charges $100 per...

    A friend of yours is considering two cell phone service providers. Provider A charges $100 per month for the service regardless of the number of phone calls made. Provider B does not have a fixed service fee but instead charges $1 per minute for calls. Your friend's monthly demand for minutes of calling is given by the equation QD=120−30P QD=120−30P, where P is the price of a minute. 1. With Provider A, the cost of an extra minute is ?...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT