Created
March 27, 2013 21:11
-
-
Save seyDoggy/5258040 to your computer and use it in GitHub Desktop.
PSPC Chapter 9 Assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem Solving and Programming Concepts | |
Adam Merrifield (2697795). | |
Chapter 9 Assignment | |
################################ | |
start | |
GetResponse() | |
stop | |
GetResponse() | |
Declarations | |
num QUIT = 0 | |
string message = "Plan type: health or auto? (" QUIT " to quit) --> " | |
string plan = prompt(message) | |
num premium | |
while (plan != QUIT) | |
premium = setPremium(plan) | |
printPremium(plan, premium) | |
plan = prompt(message) | |
endwhile | |
return | |
string prompt(string msg) { | |
Definitions | |
string planName | |
output msg | |
input planName | |
return | |
num prompt(string msg, num X) { | |
Definitions | |
num tickets | |
output msg | |
input tickets | |
return | |
setPremium(string policy) | |
Definitions | |
num premium | |
if (policy == "health") | |
premium = health() | |
else | |
premium = auto() | |
endif | |
return | |
health() | |
Declarations | |
string message = "Do you smoke? yes or no? -->" | |
string isSmoker | |
num premium | |
isSmoker = prompt(message) | |
if (isSmoker == "yes") | |
premium = 250 | |
else | |
premium = 190 | |
endif | |
return | |
auto() | |
Declarations | |
string message = "How many traffic tickets have you received in the last 3 years? -->" | |
string tickets | |
num premium | |
num x = 0 | |
tickets = prompt(message, x) | |
if (tickets > 2) | |
premium = 175 | |
else | |
premium = 140 | |
endif | |
return | |
printPremium(string plan, num premium) | |
output "Your " plan " premium is $" premium " per month." | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment