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

Write a program in PHYTON that calculates and prints the bill for a cellular tel

ID: 3755355 • Letter: W

Question

Write a program in PHYTON that calculates and prints the bill for a cellular telephone company. The company offers two types of service: regular and premium. Its rates vary, depending on the type of service. The rates are computed as follows: Regular service: $10.00 plus first 50 minutes free. Charges for over 50 minutes are $0.20 per minute. Premium service: $25.00 plus: a) For calls made from 6:00 am to 6:00 pm, the first 75 minutes are free; charges for over 75 minutes are $0.10 per minute. b) For calls made from 6:00 pm to 6:00 am, the first 100 minutes are free; charges for over 100 minutes are $0.05 per minute; Your program should prompt the user to enter an account number, a service code, and the number of minutes the service was used (type int). A service code of r or R means regular service; a service code of p or P means premium service. Treat any other character as a invalid data. Your program should output the account number, type of service, number of minutes the telephone service was used, and the amount due from the user. For premium service, the customer may be using the service during the day and the night. Therefore, to calculate the bill, you must ask the user to input the number of minutes the service was used during the day and the number of minutes the service was used during the night. Write a program in PHYTON that calculates and prints the bill for a cellular telephone company. The company offers two types of service: regular and premium. Its rates vary, depending on the type of service. The rates are computed as follows: Regular service: $10.00 plus first 50 minutes free. Charges for over 50 minutes are $0.20 per minute. Premium service: $25.00 plus: a) For calls made from 6:00 am to 6:00 pm, the first 75 minutes are free; charges for over 75 minutes are $0.10 per minute. b) For calls made from 6:00 pm to 6:00 am, the first 100 minutes are free; charges for over 100 minutes are $0.05 per minute; Your program should prompt the user to enter an account number, a service code, and the number of minutes the service was used (type int). A service code of r or R means regular service; a service code of p or P means premium service. Treat any other character as a invalid data. Your program should output the account number, type of service, number of minutes the telephone service was used, and the amount due from the user. For premium service, the customer may be using the service during the day and the night. Therefore, to calculate the bill, you must ask the user to input the number of minutes the service was used during the day and the number of minutes the service was used during the night.

Explanation / Answer

def calculateCost(data):

if(data[0]=="r"):

if(data[1]>50):

nof_mins = data[1]-50

cost = nof_mins*0.20

data[2]+=cost

else:

if(data[1]>75):

nof_day_mins = data[1]-75

cost = nof_day_mins*0.10

data[2]+=cost

if(data[2]>100):

nof_night_mins = data[2]-100

cost = nof_night_mins*0.05

data[3]+=cost

def checkServCode(servCode):

if(servCode=="p"):

return 2

elif(servCode=="r" ):

return 1

else:

return 0

def printRecords():

print("printing records of regular Accounts.....")

print("Account Number Service Nof Mins Used Due")

regularNumbers = list(regularAccounts.keys())

regularBill = list(regularAccounts.values())

premiumNumbers = list(premiumAccounts.keys())

premiumBill = list(premiumAccounts.values())

for i in range(len(regularNumbers)):

print(regularNumbers[i],regularBill[i][0],regularBill[i][1],regularBill[i][2])

print("Printing records of Premium Accounts........")

print("Account Number Service Nof Mins Used at Day Nof Mins Used at Night Due")

for i in range(len(premiumNumbers)):

print(premiumNumbers[i],premiumBill[i][0],premiumBill[i][1],premiumBill[i][2],premiumBill[i][3])

regularAccounts = {}

premiumAccounts = {}

choice = -1

while(choice):

number = int(input("Enter Account Number: "))

servCode = input("Enter Service Code (p,P - Premium.r,R - Regular)").lower()

typeCode = checkServCode(servCode)

cost = 0

if(typeCode==1):

nof_mins = int(input("Enter Nof Mins Service Used: "))

try:

test = regularAccounts[number][2]

regularAccounts[number][1]+=nof_mins

except KeyError:

regularAccounts[number] = [servCode,nof_mins,10.0]

calculateCost(regularAccounts[number])

elif(typeCode==2):

day_nof_mins = int(input("Enter Nof Mins Service Used in Day: "))

night_nof_mins = int(input("Enter Nof Mins Service Used in Night: "))

try:

test = regularAccounts[number][2]

premiumAccounts[number][1]+=day_nof_mins

premiumAccounts[number][2]+=night_nof_mins

except KeyError:

premiumAccounts[number] = [servCode,day_nof_mins,night_nof_mins,25.0]

calculateCost(premiumAccounts[number])

else:

print("Invalid Service Code")

choice= int(input("Enter 1 to continue,0 to exit"))

printRecords()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote