PDA

View Full Version : Need some Help and direction plz


xViolatorx
01-21-2009, 11:54 AM
Ok all,

Alice 2.0


I am trying to create a program for class using the code I will provide below. I am having trouble getting started. If someone would assist with some step by step to get me started,

I need to make a program that will help you decide where to go for vacation based on how much money you saved and how much vacation time you have. Those 2 pieces of info will be input but the user. This needs to run until told to stop. Below is what I have writen out in pseudo-code. Remember I am a beginner. Thanks in advance!! I left justified to try to make it a bit easier to read, it was spread out all over.


start
num moneySaved
num vacationTime
string destinations
string DEST1 = “Europe”
string DEST2 = “United Kingdom”
string DEST3 = “South America”
string DEST4 = “Caribbean”
string DEST5 = “Orlando”
string DEST1 = “Home”
RANGE1 = 1000
RANGE2 = 2000
RANGE3 = 3000
RANGE4 = 7
RANGE5 = 21
get moneySaved, vacationTime
while not eof
if moneySaved >= RANGE3 and vacationTime > RANGE5 then
destination = DEST1, DEST2, DEST3, DEST4, DEST5, DEST6
else
if moneySaved < RANGE3 and vacationTime > RANGE5 then
destination = DEST2, DEST4, DEST5, DEST6
else
If moneySaved < RANGE2 and vacationTime > RANGE5 then
destination = DEST5, DEST6
else
if moneySaved < RANGE1 and vacationTime > RANGE5 then
destination = DEST6
else
if moneySaved >= RANGE3 and vacationTime < RANGE5 then
destination = DEST3, DEST4, DEST5, DEST6
else
if moneySaved < RANGE3 and vacationTime < RANGE5 then
destination = DEST4, DEST5, DEST6
else
If moneySaved < RANGE2 and vacationTime < RANGE5 then
destination = DEST5, DEST6
else
if moneySaved < RANGE1 and vacationTime < RANGE5 then
destination = DEST6
else
if moneySaved >= RANGE3 and vacationTime < RANGE4 then
destination = DEST5, DEST6
else
if moneySaved < RANGE3 and vacationTime < RANGE4 then
destination = DEST5, DEST6
else
If moneySaved < RANGE2 and vacationTime < RANGE4 then
destination = DEST5, DEST6
else
if moneySaved < RANGE1 and vacationTime < RANGE4 then
destination = DEST6
else
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
print “Congratulations, based on the money you have saved” , moneySaved
print “and the vacation days you have” , vacationTime
print “Your vacation Destination choices are” , destination
endwhile
stop

xViolatorx
01-22-2009, 08:28 AM
Please, anyone? I just need to get started, say from the first IF/THEN/ELSE

rich0e0rick
01-22-2009, 10:38 AM
try explaining more what your program is supposed to do... are those the only options?

if so, i would do it in button style, since it would be much easier..

as in, first is says to pick your $, then etc..., saving each answer until the end...

:D:D rick :D:D

xViolatorx
01-22-2009, 10:57 AM
Rick,

Thanks for the response. Basically I have been tasked to create a program with in alice to help you decide where you will go for vacation. Its is based on a couple of parameters. The code above, is what I wrote out to try to do that very thing. Here is the constraints of my assignment:

In this assignment, you will determine where you will spend your vacation this coming summer. You have decided to plan, develop, and produce a software program that will automatically make this choice for you. Your choices are listed in the table below.

Vacation Plans Time Off Savings Destination
>= 3 weeks >$3000 Europe
>= 3 weeks >$2000 to <$3000 United Kingdom
1 to < 3 weeks >$3000 South America
1 to < 3 weeks >$2000 to <$3000 Caribbean
< 1 week >$1000 to <$2000 Orlando
< 1 week <$1000 Home


Relational comparisons in the table are equal to (=), greater than (>), less than (<), greater than or equal to (>=), less than or equal to (<=) and not equal to (<>).
Your program is required to have the following additional functionality:

The program should run until it is told to stop.
The program should include a feature that prints out the result of your search. Consider whether you need to add a section that is not in the above table.
The program should use nested decisions, and not case-break logic.


I have been reading through ~Learn to Program using Alice, by Richard G. Baldwin, and I am getting closer to understanding what I need to do. But, I am having trouble getting started. I am close and I can feel it, but i have a wall that I just cant climb with out a little direction. Thanks again for the help. I look forward to your response.

DrJim
01-23-2009, 12:16 PM
Not really sure what specifically is giving you problems, but I attached a bit of code for a starting point. You will need to write the other two methods and do some work on the input and output - but it should give you the basic idea. If you want it to run forever, you'll also need to put the starting blocks of code inside an infinite loop.

Note that the problem as you stated it doesn't include what to do for a long vacation but no money. I just guessed that the suggestion was to stay home - but you might want to check the original problem.

The only way to get a hard copy of the printout is to open the error console and copy out the text box printout part. You can't get a hard copy from within Alice.

For something like this, Dick Baldwin's tutorials are often useful - he has a lot of example code in them. You might want to do a search for specific items rather than just reading through them.

xViolatorx
01-24-2009, 11:29 AM
Dr. Jim,


Thank you so much, your nested if file was the door I needed opened. Seeing what you did there allowed me to complete almost all of what I needed to do. I guess just seeing it allowed me to make sense of it. You Rock!!! One more thing if you dont mind, I will attach what I was able to create with your help.
Before the questions are asked, I need to insert another question to ask IF you would like to continue, if yes is selected, the program will need to ask the remaining 2 questions and continue wit hthe rest of the program. If no is selected, I need the program to stop. Could you give me a little help with this?

xViolatorx
01-24-2009, 12:41 PM
Disregard Sir!!!!

I did a search for "stop loop" and found a post you made about a chicken Spin again loop. It took me a while to figure out why my yes no question wasn't working, it was all about placement and I got rid of the loop. Replaced the loop with a "while" created another t/f variable set to true, but at first it would either not work or continually loop with the yes/no question. I finally tried to palce it at the end of the "while" area, and it worked perfectly. Thank you for your help. With out you I probably would have failed my class. Thanks again


Just so anyone can see the final product, I have it attached below