Lab 8: Cell Phone Bill Calculator Write the Python code for the following progra
ID: 3624737 • Letter: L
Question
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 ask the user how many minutes were used during the month and how many minutes they were allowed. Validate the input as follows:
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 not over 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 the number 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 that month.
Use the following functions in your program design
Your sample output might look as follows (note the validation code):
Sample 1 Showing Validation:
How many minutes are allowed: 1000
Please enter minutes between 100 and 700
How many minutes are allowed: 801
Please enter minutes between 100 and 700
How many minutes are allowed: 350
How many minutes were used: -10
Please enter minutes used of at least 0
How many minutes were used: 400
You were over your minutes by 50
---------------MONTHLY USE REPORT------------------
Minutes allowed were 350
Minutes used were 400
Minutes over were 50
Total due is $ 72.45
Do you want to end program? (Enter no or yes): NO
Please enter a yes or no
Do you want to end program? (Enter no or yes): 9
Please enter a yes or no
Do you want to end program? (Enter no or yes): no
Sample 2 Showing Minutes Over:
How many minutes are allowed: 600
How many minutes were used: 884
You were over your minutes by 284
---------------MONTHLY USE REPORT------------------
Minutes allowed were 600
Minutes used were 884
Minutes over were 284
Total due is $ 107.55
Do you want to end program? (Enter no or yes): no
Sample 3 Showing Minutes Not Over:
How many minutes are allowed: 400
How many minutes were used: 379
You were not over your minutes for the month
---------------MONTHLY USE REPORT------------------
Minutes allowed were 400
Minutes used were 379
Minutes over were 0
Total due is $ 64.95
Do you want to end
program? (Enter no or yes): yes
The Python Code
Explanation / Answer
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(' ')
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 >= 100) and (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))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.