72.1k views
0 votes
An internet service provider has three different subscription package for its customers:Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.Package C: For $19.95 per month unlimited access is provided.Write a program that calculates acustomer's monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A,B,C) and the number of hours that were used.It should then display the total charges. In addition calculate and display the amount of money Package A customers would save if they purchases Package B or C, and the amount of money package B customers would save if they purchased Package C. If there would be no savings, no message should be printed.

User DrMarbuse
by
5.5k points

1 Answer

2 votes

Answer:

# The user is prompt for input to enter type of package

# the received input is capitalize

selected_package = str(input("Enter the package that you purchased.")).capitalize()

# The user is prompt for input to enter number of hours

hours_used = int(input("Enter the hours that you use for the purchased package."))

# Basic price for package a

base_price_package_a = 9.95

# Basic price for package b

base_price_package_b = 13.95

# Basic price for package c

base_price_package_c = 19.95

# additional price for package a

additional_price_a = 2

# additional price for package b

additional_price_b = 1

# total charge for the entire internet consumption

total_charges = 0

# if user entered A

if(selected_package == str('A')):

# additionail hour is calculated

extra_hour = hours_used - 10

# total_charge is calculated for package a

total_charges = base_price_package_a + (extra_hour * additional_price_a)

# total charge for package a is displayed

print("Your total charges using package A is: $",total_charges)

# if user entered B

elif(selected_package == str('B')):

# additionail hour is calculated

extra_hour = hours_used - 20

# total_charge is calculated for package b

total_charges = base_price_package_b + (extra_hour * additional_price_b)

# total charge for package b is displayed

print("Your total charges using package B is: $",total_charges)

# if user entered C

elif(selected_package == str('C')):

print("You bought package C")

# amount to be saved

amount_saved = 0

# if user bought package A and total charge exceed 13.95

if (selected_package == str('A') and total_charges > base_price_package_b):

# amount saved if package a is bought is calculated relative to package b

amount_saved = total_charges - base_price_package_b

# amout saved is printed

print("You would have saved $",amount_saved, " if you bought package B")

# amount saved if package a is bought is calculated relative to package c

amount_saved = total_charges - base_price_package_c

# amout saved is printed

print("You would have saved $",amount_saved, " if you bought package C")

# if user bought package B and total charge exceed 19.95

elif(selected_package == str('B') and total_charges > base_price_package_c):

# amount saved if package b is bought is calculated relative to package c

amount_saved = total_charges - base_price_package_c

# amout saved is printed

print("You would have saved $",amount_saved, " if you bought package C")

Step-by-step explanation:

The code is written in python and well commented.

User Ravi Kumar Mistry
by
4.9k points