Plan the logic for an insurance company’s premium-determining program (flowchart
ID: 3633523 • Letter: P
Question
Plan the logic for an insurance company’s premium-determining program (flowchart and psuedocode).The program calls a method that prompts the user for the type of policy needed—health or auto. Pass the user’s response to a second method, where the premium is set—$250 for a health policy or $175 for an auto policy. Pass the premium amount to a third module for printing
(B)
Modify Exercise (a) so that the second method calls one of two additional methods—one that determines the health premium or one that determines the auto premium. The health insurance method asks users whether they smoke; the premium is $250 for smokers and $190 for nonsmokers. The auto insurance method asks users to enter the number of traffic tickets they have received in the last three years. The premium is $175 for those with three or more tickets, $140 for those with one or two tickets, and $95 for those with no tickets. Each of these two methods returns the premium amount to the second method, which sends the premium amount to the printing module.
Explanation / Answer
start num premium num policyNum num premiumVal policyNum = policyNeeded() premium = premiumVal(policyNum) premiumMessage(premiumVal) stop policyNeeded() num policyCode string errortext = "" boolean policycodeOK = false while policycodeOK = false print errorText & "Type of policy needed? (1 for health, 2 for auto)" get policyCode if policyCode = 2 OR policyCode = 1 policycodeOK = true else errorText "Please re-enter a valid policy number" endif while end return policyCode premiumVal(policyNum) num premium if 1 premium = 250 else premium = 175 endif return premium premiumMessage(premium) string TWO_FIDDY = "Your health premium will be $250.00." string ONE_SETTY = "Your auto premium will be $175.00." if premium = 250 print TWO_FIDDY else print ONE_SETTY endif