# Num quit 1 string prompt enter an area code or 1 to

• 981
• 70% (23) 16 out of 23 people found this document helpful

This preview shows page 546 - 551 out of 981 pages.

##### We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
The document you are viewing contains questions related to this textbook.
Chapter PC / Exercise 10
Elementary Geometry for College Students
Alexander/Koeberlein
Expert Verified
num QUIT = -1 string PROMPT = “Enter an area code or -1 to quit >> ” housekeeping()
##### We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
The document you are viewing contains questions related to this textbook.
Chapter PC / Exercise 10
Elementary Geometry for College Students
Alexander/Koeberlein
Expert Verified
while custAreaCode <> QUIT deailLoop() endwhile finish() stop housekeeping() output PROMPT input custAreaCode return detailLoop() input custPhoneNum, numTxtMsgs beforeTaxCost = BASE_RATE if numTxtMsgs > MIN_MSGS then if numTxtMsgs > MAX_MSGS then beforeTaxCost = beforeTaxCost + (MAX_MSGS – MIN_MSGS) * MIN_RATE + (numTxtMs * MAX_RATE else beforeTaxCost = beforeTaxCost + (numTxtMsgs – MIN_MSGS) * MIN_RATE endif endif taxes = beforeTaxCost * TAX_RATE afterTaxCost = beforeTaxCost + taxes if afterTaxCost > DISPLAY_AMT then output custAreaCode, custPhoneNum, numTxtMsgs, beforeTaxCost, afterTaxCost endif output PROMPT input custAreaCode return finish() output “End of program” return e. A program that prompts the user for a three-digit area code from which to select bills. Then Answer : A sample solution is as follows: Flowchart: Pseudocode:
start Declarations num custAreaCode num displayAreaCode num custPhoneNum num numTxtMsgs num taxes num beforeTaxCost num afterTaxCost num BASE_RATE = 5 num MIN_MSGS = 60 num MAX_MSGS = 180 num DISPLAY_MSGS = 100 num MIN_RATE = 0.05 num MAX_RATE = 0.10 num TAX_RATE = 0.12 num QUIT = -1 string DATA_PROMPT = “Enter an area code or -1 to quit >> ” string INIT_PROMPT = “Enter an area code from which to select bills >> ” housekeeping() while custAreaCode <> QUIT detailLoop() endwhile finish() stop housekeeping() output INIT_PROMPT input displayAreaCode output DATA_PROMPT input custAreaCode return detailLoop() if custAreaCode = displayAreaCode then input custPhoneNum, numTxtMsgs beforeTaxCost = BASE_RATE if numTxtMsgs > MIN_MSGS then if numTxtMsgs > MAX_MSGS then beforeTaxCost = beforeTaxCost + (MAX_MSGS – MIN_MSGS) * MI (numTxtMs * MAX_RATE else beforeTaxCost = beforeTaxCost +
(numTxtMsgs – MIN_MSGS) * endif endif taxes = beforeTaxCost * TAX_RATE afterTaxCost = beforeTaxCost + taxes output custAreaCode, custPhoneNum, numTxtMsgs, beforeTaxCost, afterTaxCost endif output DATA_PROMPT input custAreaCode return finish() output “End of program” return 7. The Drive-Rite Insurance Company provides automobile insurance policies for drivers. D a. A program that accepts insurance policy data, including a policy number, customer last na Answer : A sample solution is as follows: Flowchart: Pseudocode: start Declarations num policyNumber num age num dueMonth num dueDay num dueYear num accidents string lastName string firstName housekeeping() detail() finish() stop housekeeping() output “Insurance program”
in dueYear, accidents return detail() if policyNumber < 1000 OR policyNumber > 9999 then policyNumber = 0 endif if dueMonth < 1 OR dueMonth > 12 OR dueDay < 1 OR dueDay > 31 then dueMonth = 0 dueDay = 0 dueYear = 0 else if (dueMonth = 2 AND dueDay > 29) OR ((dueMonth = 4 OR dueMonth = 6 OR dueMonth = 9 OR dueMonth = 11) AND dueDay > 30) then dueMonth = 0 dueDay = 0 dueYear = 0 endif endif output po dueYear, accidents return finish() output “End of program” return b. A program that continuously accepts policy holders’ data until a sentinel value has been e Answer : A sample solution is as follows: Flowchart: Pseudocode: start Declarations num policyNumber num age num dueMonth num dueDay num dueYear num accidents string lastName