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")
Explanation:
The code is written in python and well commented.