Write a program that calculates 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: R100 + The first 50 mins are free + R2 per minute for mins over 50.· Premium Service: R250 +a. For calls from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free; charges for more than 75 minutes are R1 per minute.b. For calls from 6:00 p.m. to 6:00 a.m., the first 100 minutes are free; charges for more than 100 minutes are R0.5 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. 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 an error.For the premium service, the customer may use 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. Your program should then generate an invoice by writing the account number, type of service, number of minutes the telephone service was used, and the amount due to a file called bill.txt.
Question
Write a program that calculates 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: R100 + The first 50 mins are free + R2 per minute for mins over 50.· Premium Service: R250 +a. For calls from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free; charges for more than 75 minutes are R1 per minute.b. For calls from 6:00 p.m. to 6:00 a.m., the first 100 minutes are free; charges for more than 100 minutes are R0.5 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. 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 an error.For the premium service, the customer may use 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. Your program should then generate an invoice by writing the account number, type of service, number of minutes the telephone service was used, and the amount due to a file called bill.txt.
Solution
Sure, here is a Python program that fulfills the requirements:
def calculate_bill():
account_number = input("Enter account number: ")
service_code = input("Enter service code (r or p): ")
day_minutes = 0
night_minutes = 0
if service_code.lower() == 'r':
total_minutes = int(input("Enter total minutes: "))
if total_minutes > 50:
bill = 100 + (total_minutes - 50) * 2
else:
bill = 100
service_type = 'Regular'
elif service_code.lower() == 'p':
day_minutes = int(input("Enter day minutes: "))
night_minutes = int(input("Enter night minutes: "))
total_minutes = day_minutes + night_minutes
if day_minutes > 75:
day_bill = (day_minutes - 75) * 1
else:
day_bill = 0
if night_minutes > 100:
night_bill = (night_minutes - 100) * 0.5
else:
night_bill = 0
bill = 250 + day_bill + night_bill
service_type = 'Premium'
else:
print("Invalid service code.")
return
with open('bill.txt', 'w') as f:
f.write(f"Account number: {account_number}\n")
f.write(f"Type of service: {service_type}\n")
f.write(f"Number of minutes the telephone service was used: {total_minutes}\n")
f.write(f"Amount due: R{bill}\n")
print("Invoice generated in bill.txt file.")
calculate_bill()
This program first asks for the account number and service code. If the service code is 'r' or 'R', it asks for the total minutes and calculates the bill for regular service. If the service code is 'p' or 'P', it asks for the day and night minutes separately and calculates the bill for premium service. If the service code is neither 'r' nor 'p', it prints an error message. Finally, it writes the account number, type of service, total minutes, and bill amount to a file named 'bill.txt'.
Similar Questions
Customers of a phone company can choose between two service plans for long distance calls. The first plan has a $26 monthly fee and charges an additional $0.13 for each minute of calls. The second plan has a $15 monthly fee and charges an additional $0.17 for each minute of calls. For how many minutes of calls will the costs of the two plans be equal?
Darius is comparing phone plans. If he chooses Cellular Unlimited, he could buy a phone for $390 and pay $7.50 per month for service. If he chooses Worldwide Wireless, he would pay $19.75 per month for service but would get a phone for free. In addition, Worldwide Wireless is offering new customers a $100 signing bonus.Which equation can you use to find m, the number of months it would take for the total cost to be the same for either plan?7.5m+390=19.75m–1007.5m+390=19.75m+100After how many months would the total cost be the same for either plan?Simplify any fractions. monthsSubmit
Write an expression for the total cost (in dollars) of a call lasting t𝑡 minutes.
The credit remaining on a phone card (in dollars) is a linear function of the total calling time made with the card (in minutes). The remaining credit after 35 minutes of calls is $15.10, and the remaining credit after 46 minutes of calls is $13.56. What is the remaining credit after 51 minutes of calls?CallingtimeinminutesRemainingcreditindollars$1
A phone company has a texting plan that charges a monthly rate based on the number of texts an individual sends per month. This is modeled by the function cost of plan, 𝐶(𝑥),𝐶(𝑥), in dollars, is a function of the number of texts sent, 𝑥𝑥, per month.𝐶(𝑥)=⎧⎩⎨⎪⎪250.05𝑥+25.075𝑥+25 if 𝑥<100 if 100≤𝑥≤500 if 500<𝑥𝐶(𝑥)={25 if 𝑥<1000.05𝑥+25 if 100≤𝑥≤500.075𝑥+25 if 500<𝑥If you sent 500500 texts last month, what was the cost of your bill from the phone company? Question 2Answera.$37.50$37.50 b.$50.00$50.00c.$25.00$25.00d.$62.50
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.