Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab 8: Cell Phone Bill Calculator Write the Python code for the following progra

ID: 3633402 • 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:

• 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 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:
• 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):

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))