is programming example taken out of the textbook by D.S. Malik demonstrates a program that calculates a customer’s bill for a local cable company. There are two types of customers: residential and business. There are two rates for calculating a cable bill: one for residential customers and one for business customers. For residential customers the following rates apply:
For business customers the following rates apply:
write the flowchart and pseucode for question
function main()
output "Enter account number (an integer): "
input accountNumber
output "Enter customer type: R or r (Residential), B or b (Business)"
input customerType
if customerType = "r" OR customerType = "R" then
output "Enter the number of premium channels:"
input numOfPremChannels
amountDue = 4.50 + 20.50 + numOfPremChannels * 7.50
else
if customerType = "b" OR customerType = "B" then
output "Enter number of basic service connections: "
input numOfBasicServConn
output "Enter number of premium channels: "
input numOfPremChannels
if numOfBasicServConn <= 10 then
amountDue = 15.00 + 75.00 + numOfPremChannels * 50.00
else
amountDue = 15.00 + 75.00 + (numOfBasicServConn - 10) * 5.00 + numOfPremChannels * 50.00
end If
end If
end If
output "Account Number: " + accountNumber
output "Amount Due: $" + amountDue
end function
Comments
Leave a comment