De sign (pseudocode) for a program ( name it PhoneB ill ) that calculates the bi
ID: 3748483 • Letter: D
Question
Design (pseudocode) for a program (name it PhoneBill) that calculates the bill for a cellular telephone company. The company offers two types of service: regular servicer and premium service. The rates vary depending on the type of service. The rates are computed as follows:
Regular service:$15.00 fee covering first 50 minutes. Charges for over 50 minutes are computed at the rate of $0.50 per minute.
Premium service:$25.00 fee plus:
a.For daytime calls (between 6:00AM to 6:00PM), the first 50 minutes are free; charges for over 50 minutes are computed at the rate of $0.20 per minute.
b.For nighttime calls (between 6:00PM to 6:00AM), the first 100 minutes are free; charges for over 100 minutes are computed at the rate of 0.10 per minute.
The program prompts the user to enter an account number, a service code (of type char), and the number of minutes the service was used. A service code r (or R) means regular service; while code p (or P) means premium service.
If the service is premium (code p or P), the customer may be using the service during both the day and night. Therefore, the program must ask the user to input the number of minutes used during daytime and nighttime in separate prompts.
Document your code and properly label the input prompts and the outputs as shown below.
Sample run 1:
Account Number:12345
Service type:Regular
Total minutes:50
Amount due:$15.00
Sample run 2:
Account Number:32145
Service type:Premium
Daytime minutes:40
Nighttime minutes:200
Amount due:$35.00
Sample run 3:
Account Number:78654
Service type:Premium
Daytime minutes:60
Nighttime minutes:120
Amount due:$29.00
Explanation / Answer
#Phonebill
-----------------------------------------------------------------------------------
prompt the user for account number
save the input to acc_no
prompt the user for service code
save the input to svc_code
prompt the user for usage ( no of minutes used )
save the input to usage_mins
if svc_code==p ||svc_code==P
prompt the user for daytime usage
save the input to usage_day
prompt the user for night usage
save the input to usage_night
initialize day_bill and night_bill equal to 0 (zero)
if usage_day > 50
day_bill = (usage_day - 50) * 0.20
if usage_night > 100
night_bill = (usage_night - 100) * 0.10
final_bill = 25 + day_bill + night_bill
else if svc_code==r ||svc_code==R
initialize out_bill = 0
if usage_mins > 50
out_bill = (usage_mins - 50) * 0.50
final_bill = 15 + out_bill
print Amount due: $ (final_bill)
---------------------------------------------------------------------------------------------------------------
I hope the code is pretty much self explanatory. If you have any concerns please write in comments.
Thank you.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.