Computer Science Canada

Quiz program - elsifs and loops problems

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 7:40 pm ]
Post subject:  Quiz program - elsifs and loops problems

Okay I have a class, which we use turing, but I'm not good with programing. I have this project which I need a good grade on this project to pass, if possible could someone help me with my project to get it working. I was up until 3 in the morning last night but still I had problems.
code:

const sentinel := "end"
var answer : string
var ans1 : int


%Colors the background a green color
colorback (grey)
for count : 1 .. 80
    delay (11)
    put "*"
    locate (1, count)
end for

for row : 2 .. 23
    delay (11)
    locate (row, 1)
    put "*                                                                            **"
    locate (row, 2)
    put "*                                                                            **"
end for

for count : 1 .. 80
    delay (11)
    put "*"
    locate (24, count)
    delay (11)
end for

for count : 3 .. 79
    delay (11)
    put "*"
    locate (18, count)
end for




loop
    color (2)
    put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
    get answer
    exit when answer = "yes"
    if answer = "no" then
   
        put " "
        color (blue)
        put " Do you use the term NOOB?  yes or no"
     
        get answer
        exit when answer ="no"
        if answer= "yes" then


       
     
  put" When you get a headshot kill in a first person shoot, do you say BOOOOM HEADSHOT? Yes or No "
        get answer
        exit when answer= "No"
        if answer="yes" then
        put" When you here the word camping do you instantly thinking about campers in a FPS? Yes or No"
        get answer
        exit when answer= "No"
        if answer = "Yes" then
       
       put" The first thing that comes to your mind when you here CS is.. (1) Computer Science or (2) Counter-Strike
       get answer
       exit when answer = "1"
       if answer= "2" then
       put" Do you run around your house  pretending you're hold a guy and make gun sounds and say I can dance all day I can dance all day try hitting him noob? Yes or No
       get answer
       exit when answer= " No"
       if answer= "Yes" then
       put " When you see a gun in a movie can you recognize it right away?  yes or no"
        color (red)
 
     get answer
        exit when answer ="no"
        if answer= "yes" then

       

   
        %Comment on your answer
        case answer of
            label 1 :
                put "Wow you have nice good eyes."
                put "Let me ask you another question ."
           
        end case
       


        %Ask the 7th question
        color (blue)
        put " "
        put "Your third question is.."
        put "which of these reason do you think is the best reason you play FPS? Choose from 1 to 5 "
        color (100)
        put "(1)Hockey not violent and bloody enough (2)Not enough people shooting at you on slight in real life (3) I just want to blow something up (4)Already got kicked out of the real army (5) I'm just bored and want to play something : " ..
        get answer
        exit when answer= "(5) I'm bored and want to play something"
        if answer="(1)Hockey not violent and bloody enough" "(2)Not enough people shooting at you on slight in real life" "(3) I just want to blow something up" "(4)Already got kicked out of the real army"
        put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War 
        color (red)
       get answer
        if answer=" World War 2
        put" Your battlefield game is Battlefield 1942 and you played the game? Yes or No"
        get answer
        exit when answer= " No"
        if answer= "Yes" then
        put" If you have made it this far you are 100% addicted to first person shooters"
         loop
    color (2)
    put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
    get answer
    exit when answer = "no"
    if answer = "Yes" then
    put" Now don't you feel better for telling the truth?"
        if answer = " Vietnam War"
        put" Your Battlefield game is Battleifield Vietnam have you play this game? Yes or No"
        get answer
        exit when answer= " No"
        if answer= "Yes" then
        put" If you have made it this far you are 100% addicted to first person shooters"
         loop
    color (2)
    put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
    get answer
    exit when answer = "no"
    if answer = "Yes" then
    put" Now don't you feel better for telling the truth?"
        if answer= "Iraq War"
        put" Your Battlefield game is Battlefield 2 have you played this game? Yes or No "
        get answer
        exit when answer= " No"
        if answer= "Yes" then
        put" If you have made it this far you are 100% addicted to first person shooters"
         loop
    color (2)
    put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
    get answer
    exit when answer = "no"
    if answer = "Yes" then
    put" Now don't you feel better for telling the truth?"
end if
    end loop

 end loop


Can someone please fix it up for me so it cna run and post it back here? Crying or Very sad

Author:  Cervantes [ Wed Apr 26, 2006 7:48 pm ]
Post subject: 

Welcome to CompSci.ca

First, we don't do homework for people. It's good that you've given it a try, but it's unethical for anyone to rewrite your code and then you hand it in as your own. Furthermore, you don't learn anything that way.

Second, please use [code][/code] tags when posting code. It will keep whatever indentation you may have had. Non-indented code is essentially unreadable, and lowers the chances of getting help.

Third, you need to ask a question. What is wrong with your program? How exactly does it need to be fixed up?

Fourth, use a descriptive topic title. We know you need help, because you're posting in a help forum. Saying it's urgent doesn't really help you at all, since you'll get help as soon as someone willing reads your post. Posting ASAP probably won't make anyone more willing to help you. It is a little annoying that you think your thread deserves more attention than the others.

Finally, check out the Turing Walkthrough. There are tutorials you'll find from there that will make this program a lot easier. You'd probably want to learn about arrays, records and types, procedures and functions, and maybe files.

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 7:55 pm ]
Post subject: 

Okay thanks for the reply, I don't know why doesn't it work, if someone can tell me why it doesn't work. I've tried to figure it out but I don't know how? I think I need an elsif statement, but not sure, how to do so. I just doesn't run, for example I get this message " string literal ends at end of line" I don't know what does that mean. I understand that it wouldn't be right for me to ask you to fix up my work and I hand it in, all I want is for someone to tell me what I'm doing wrong and how to fix it.

Author:  Cervantes [ Wed Apr 26, 2006 8:05 pm ]
Post subject: 

code:

  put" When you get a headshot kill in a first person shoot, do you say BOOOOM HEADSHOT? Yes or No "
        get answer
        exit when answer= "No"
        if answer="yes" then
        put" When you here the word camping do you instantly thinking about campers in a FPS? Yes or No"
        get answer
        exit when answer= "No"
        if answer = "Yes" then
       
       put" The first thing that comes to your mind when you here CS is.. (1) Computer Science or (2) Counter-Strike
       get answer
       exit when answer = "1"
       if answer= "2" then
       put" Do you run around your house  pretending you're hold a guy and make gun sounds and say I can dance all day I can dance all day try hitting him noob? Yes or No

You need quotation marks at the end of a string. You might have this problem elsewhere.

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 8:10 pm ]
Post subject: 

Yeah I figured that out, that part is okay now ( guess I was too tired last night and forgot about puting " ) since it's not highlighted when I try to run it.
Now I'm doing this:
code:
put " "
        put "Your third question is.."
        put "which of these reason do you think is the best reason you play FPS? Choose from 1 to 5 "
        color (100)
        put "(1)Hockey not violent and bloody enough (2)Not enough people shooting at you on slight in real life (3) I just want to blow something up (4)Already got kicked out of the real army (5) I'm just bored and want to play something : " ..
        get answer
        exit when answer= "(5) I'm bored and want to play something"
        if answer="1"   "3" "4" then
        put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"
        elsif answer= "2" then put
       put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"
       


Am I on the right track by adding the elsif statements and am I doign it right?
BTW thanks for helping me out.

Author:  Clayton [ Wed Apr 26, 2006 8:12 pm ]
Post subject: 

your code is also all over the place, i counted like 12 missing end ifs, which i have no idea where they go, you are missing end quotes, you are missing the "then" after your if conditions, i think you need to take time and pay attention to what you are typing a bit more carefully, a little bit of planning would help too

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 8:17 pm ]
Post subject: 

SuperFreak82 wrote:
your code is also all over the place, i counted like 12 missing end ifs, which i have no idea where they go, you are missing end quotes, you are missing the "then" after your if conditions, i think you need to take time and pay attention to what you are typing a bit more carefully, a little bit of planning would help too

Yeah I know I was really in a hurry, now I think I fixed this part is it right
code:
if answer="1"   then
        put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"
        elsif answer= "2" then
       put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"
         
       elsif answer= "3" then
       put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"
         
       elsif answer= "4" then
       put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War

Also about the missing end ifs I'm doign what I can fix now then after all that is fix I'm gonna worry abotu the end if. What does syntax error at 'put' , expected then" mean?

Author:  Clayton [ Wed Apr 26, 2006 8:31 pm ]
Post subject: 

it means you probably have an if statement before you have your put statement and you forgot to put "then" after your condition eg.
code:

if x=maxx then %this is the then i was talking about
put maxint
end if
%what you are having the problem with i think
if x=maxx
put maxint
end if
%this creates a run-time error, make sure you have then after your condition

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 8:35 pm ]
Post subject: 

Okay this is the part that is wrong
code:
ut "Are You Addiicted To First Person Shooters ?? yes or no: " ..
    get answer
    exit when answer = "no"
    if answer = "Yes" then
    put" Now don't you feel better for telling the truth?"
        if answer = " Vietnam War"
        [b]put" Your Battlefield game is Battleifield Vietnam have you play this game? Yes or No" then[/b]
        get answer
        exit when answer= " No"
        if answer= "Yes" then
        put" If you have made it this far you are 100% addicted to first person shooters"


know what I'm doing wrong. BTW thanks for the help.

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 8:36 pm ]
Post subject: 

^^^^ NVM I found where I didn't put then? Shocked

Author:  Clayton [ Wed Apr 26, 2006 8:38 pm ]
Post subject: 

your "then" is in the wrong spot, move it to after the if condition, not your text you are putting to the screen

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 8:39 pm ]
Post subject: 

Okay sorry for the replies after another, this forums really need a edit option. Okay I have one error now and it's syntax error at ' End of File', expected ' end if' but I alreayd have a end if at the end of the program.

Author:  HellblazerX [ Wed Apr 26, 2006 8:42 pm ]
Post subject: 

you probably forgot an end if, so just add one. Just press F2 to indent. You can tell where you're missing an end if or end loop if your program is not properly indented.

Author:  Clayton [ Wed Apr 26, 2006 8:42 pm ]
Post subject: 

put in another one, you might still be missing one

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 8:46 pm ]
Post subject: 

SuperFreak82 wrote:
put in another one, you might still be missing one

just at the ned of the program anywhere?
So far this is my program I'm getting really excited about this seeing if it will work.
code:
loop
    color (2)
    put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
    get answer
    exit when answer = "yes"
    if answer = "no" then

        put " "
        color (blue)
        put " Do you use the term NOOB?  yes or no"

        get answer
        exit when answer = "no"
        if answer = "yes" then




            put " When you get a headshot kill in a first person shoot, do you say BOOOOM HEADSHOT? Yes or No "
            get answer
            exit when answer = "No"
            if answer = "yes" then
                put " When you here the word camping do you instantly thinking about campers in a FPS? Yes or No"
                get answer
                exit when answer = "No"
                if answer = "Yes" then

                    put " The first thing that comes to your mind when you here CS is.. (1) Computer Science or (2) Counter-Strike"
                    get answer
                    exit when answer = "1"
                    if answer = "2" then
                        put " Do you run around your house  pretending you're hold a guy and make gun sounds and say I can dance all day I can dance all day try hitting him noob? Yes or No"
                        get answer
                        exit when answer = " No"
                        if answer = "Yes" then
                            put " When you see a gun in a movie can you recognize it right away?  yes or no"
                            color (red)

                            get answer
                            exit when answer = "no"
                            if answer = "yes" then







                                %Ask the 7th question
                                color (blue)
                                put " "
                                put "Your third question is.."
                                put "which of these reason do you think is the best reason you play FPS? Choose from 1 to 5 "
                                color (100)
                                put
                                    "(1)Hockey not violent and bloody enough (2)Not enough people shooting at you on slight in real life (3) I just want to blow something up (4)Already got kicked out of the real army (5) I'm just bored and want to play something : "
..
                                get answer
                                exit when answer = "(5) I'm bored and want to play something"
                                if answer = "1" then
                                    put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"
                                elsif answer = "2" then
                                    put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"

                                elsif answer = "3" then
                                    put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"

                                elsif answer = "4" then
                                    put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"


                                    color (red)
                                    get answer
                                    if answer = " World War 2" then
                                        put " Your battlefield game is Battlefield 1942 and you played the game? Yes or No"
                                        get answer
                                        exit when answer = " No"
                                        if answer = "Yes" then
                                            put " If you have made it this far you are 100% addicted to first person shooters"
                                            loop
                                                color (2)
                                                put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
                                                get answer
                                                exit when answer = "no"
                                                if answer = "Yes" then
                                                    put " Now don't you feel better for telling the truth?"
                                                    if answer = " Vietnam War" then
                                                        put " Your Battlefield game is Battleifield Vietnam have you play this game? Yes or No"
                                                        get answer
                                                        exit when answer = " No"
                                                        if answer = "Yes" then
                                                            put " If you have made it this far you are 100% addicted to first person shooters"
                                                            loop
                                                                color (2)
                                                                put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
                                                                get answer
                                                                exit when answer = "no"
                                                                if answer = "Yes" then
                                                                    put " Now don't you feel better for telling the truth?"
                                                                    if answer = "Iraq War" then
                                                                        put " Your Battlefield game is Battlefield 2 have you played this game? Yes or No "
                                                                        get answer
                                                                        exit when answer = " No"
                                                                        if answer = "Yes" then
                                                                            put " If you have made it this far you are 100% addicted to first person shooters"
                                                                            loop
                                                                                color (2)
                                                                                put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
                                                                                get answer
                                                                                exit when answer = "no"
                                                                                if answer = "Yes" then
                                                                                    put " Now don't you feel better for telling the truth?"
                                                                                end if
                                                                            end loop


Thanks for all the help guys.

Author:  Clayton [ Wed Apr 26, 2006 8:47 pm ]
Post subject: 

not just anywhere, put the end if at the end of the program ("end of file")

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 8:54 pm ]
Post subject: 

SuperFreak82 wrote:
not just anywhere, put the end if at the end of the program ("end of file")


Right now this is what my prgram looks like at the end
code:
    end if
                                                                            end loop
                                                                                end of file


It still doesn't work. Crying or Very sad

Author:  Clayton [ Wed Apr 26, 2006 9:09 pm ]
Post subject: 

thats because turing doesnt end like this
Turing:

var a:int:=5
put a
end of file

this end of file thing you have doesnt exist in turing get rid of it

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 9:17 pm ]
Post subject: 

SuperFreak82 wrote:
thats because turing doesnt end like this
Turing:

var a:int:=5
put a
end of file

this end of file thing you have doesnt exist in turing get rid of it


it still doesnt run if i take away the end of file.

Author:  Clayton [ Wed Apr 26, 2006 9:17 pm ]
Post subject: 

well then i dont know whats going on with your program, post what you have and ill look over it again

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 9:23 pm ]
Post subject: 

code:
% Input: The user enters the asnwers for a series of questions
% Ouput: find out if you're addicted to FPS
% Displays if you are addicted to FPS
const sentinel := "end"
var answer : string
var ans1 : int


%Colors the background a green color
colorback (grey)
for count : 1 .. 80
    delay (11)
    put "*"
    locate (1, count)
end for

for row : 2 .. 23
    delay (11)
    locate (row, 1)
    put "*                                                                            **"
    locate (row, 2)
    put "*                                                                            **"
end for

for count : 1 .. 80
    delay (11)
    put "*"
    locate (24, count)
    delay (11)
end for

for count : 3 .. 79
    delay (11)
    put "*"
    locate (18, count)
end for




loop
    color (2)
    put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
    get answer
    exit when answer = "yes"
    if answer = "no" then

        put " "
        color (blue)
        put " Do you use the term NOOB?  yes or no"

        get answer
        exit when answer = "no"
        if answer = "yes" then




            put " When you get a headshot kill in a first person shoot, do you say BOOOOM HEADSHOT? Yes or No "
            get answer
            exit when answer = "No"
            if answer = "yes" then
                put " When you here the word camping do you instantly thinking about campers in a FPS? Yes or No"
                get answer
                exit when answer = "No"
                if answer = "Yes" then

                    put " The first thing that comes to your mind when you here CS is.. (1) Computer Science or (2) Counter-Strike"
                    get answer
                    exit when answer = "1"
                    if answer = "2" then
                        put " Do you run around your house  pretending you're hold a guy and make gun sounds and say I can dance all day I can dance all day try hitting him noob? Yes or No"
                        get answer
                        exit when answer = " No"
                        if answer = "Yes" then
                            put " When you see a gun in a movie can you recognize it right away?  yes or no"
                            color (red)

                            get answer
                            exit when answer = "no"
                            if answer = "yes" then







                                %Ask the 7th question
                                color (blue)
                                put " "
                                put "Your third question is.."
                                put "which of these reason do you think is the best reason you play FPS? Choose from 1 to 5 "
                                color (100)
                                put
                                    "(1)Hockey not violent and bloody enough (2)Not enough people shooting at you on slight in real life (3) I just want to blow something up (4)Already got kicked out of the real army (5) I'm just bored and want to play something : "
..
                                get answer
                                exit when answer = "(5) I'm bored and want to play something"
                                if answer = "1" then
                                    put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"
                                elsif answer = "2" then
                                    put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"

                                elsif answer = "3" then
                                    put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"

                                elsif answer = "4" then
                                    put "What War Ear Would You Rather Be A Part Of? World War 2 or Vietnam War or Iraq War"


                                    color (red)
                                    get answer
                                    if answer = " World War 2" then
                                        put " Your battlefield game is Battlefield 1942 and you played the game? Yes or No"
                                        get answer
                                        exit when answer = " No"
                                        if answer = "Yes" then
                                            put " If you have made it this far you are 100% addicted to first person shooters"
                                            loop
                                                color (2)
                                                put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
                                                get answer
                                                exit when answer = "no"
                                                if answer = "Yes" then
                                                    put " Now don't you feel better for telling the truth?"
                                                    if answer = " Vietnam War" then
                                                        put " Your Battlefield game is Battleifield Vietnam have you play this game? Yes or No"
                                                        get answer
                                                        exit when answer = " No"
                                                        if answer = "Yes" then
                                                            put " If you have made it this far you are 100% addicted to first person shooters"
                                                            loop
                                                                color (2)
                                                                put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
                                                                get answer
                                                                exit when answer = "no"
                                                                if answer = "Yes" then
                                                                    put " Now don't you feel better for telling the truth?"
                                                                    if answer = "Iraq War" then
                                                                        put " Your Battlefield game is Battlefield 2 have you played this game? Yes or No "
                                                                        get answer
                                                                        exit when answer = " No"
                                                                        if answer = "Yes" then
                                                                            put " If you have made it this far you are 100% addicted to first person shooters"
                                                                            loop
                                                                                color (2)
                                                                                put "Are You Addiicted To First Person Shooters ?? yes or no: " ..
                                                                                get answer
                                                                                exit when answer = "no"
                                                                                if answer = "Yes" then
                                                                                    put " Now don't you feel better for telling the truth?"
                                                                                end if
                                                                            end loop
                                                                               



sorry if it looks all over the place its because i hit indent.

Author:  Clayton [ Wed Apr 26, 2006 9:29 pm ]
Post subject: 

you are still missing a pile of end ifs at the end of your program, for every if you have you should have a corresponding end if ex.
Turing:

if iWin then
    %do whatever
end if
%this works
if uLose then
    if iWin then
        %do Whatever
    end if
%this will cause a crash because i havent finished my initial if

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 9:31 pm ]
Post subject: 

SuperFreak82 wrote:
you are still missing a pile of end ifs at the end of your program, for every if you have you should have a corresponding end if ex.
Turing:

if iWin then
    %do whatever
end if
%this works
if uLose then
    if iWin then
        %do Whatever
    end if
%this will cause a crash because i havent finished my initial if



for every if statements that i have int he program can i just put all the end ifs at the end of the program, will that work?

Author:  Clayton [ Wed Apr 26, 2006 9:38 pm ]
Post subject: 

in your case it probably will, the way you have your program set up, however, this is rarely true for most programs, just remember that

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 9:59 pm ]
Post subject: 

SuperFreak82 wrote:
in your case it probably will, the way you have your program set up, however, this is rarely true for most programs, just remember that


is there a way to tell how many if statements are in the program without actually counting?

Author:  Clayton [ Wed Apr 26, 2006 10:04 pm ]
Post subject: 

unfortunately no, however you can have the comp put the closing on an if statement by going to where you want it to be put and hit Shit+Ctrl and it will put the closing of an if(for,loop etc)statement there until it can find no more open ended statements

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 10:43 pm ]
Post subject: 

SuperFreak82 wrote:
unfortunately no, however you can have the comp put the closing on an if statement by going to where you want it to be put and hit Shit+Ctrl and it will put the closing of an if(for,loop etc)statement there until it can find no more open ended statements

Okay thanks for all the help, you were a really big help.

Author:  kickflipto50-50tobigspin [ Wed Apr 26, 2006 11:02 pm ]
Post subject: 

My program still doesn't work.

Author:  Cervantes [ Thu Apr 27, 2006 3:50 pm ]
Post subject: 

kickflipto50-50tobigspin wrote:
is there a way to tell how many if statements are in the program without actually counting?

Sure there is. Turing source code is plain text; there's nothing magical about it. So, use some programming language to open up the source file and go through each line, incrimenting a counter if it matches the regexp
code:
\Aif.+then$

"\A" is the beginning of a line
"." is any character. ".+" is at least one of any character
$ is the end of the line (I think).

(You might also want to do something to make sure there aren't any quotation marks in the line.)

If the language you want to use doesn't support regexps, then you'll have to do a little more work.

Author:  HellblazerX [ Thu Apr 27, 2006 5:46 pm ]
Post subject: 

I think the best way to fix your program is to basically rewrite it without all those if statements, otherwise, you'll confuse yourself with all those if statements, and you have something like 20+ of them, so it's hard to keep track of them. Now, if I'm not mistaken, your program works by asking the user questions, and if the user answers wrong, then the program exits. So an example would be like :
code:
loop
    put "Do head shots hurt?"
    get answer
    exit when answer not= "yes"
    //The rest of the questions
end loop

You can do all your questions like that without the if statements, and the program will do the same thing. Your code will also be alot shorter too.

Author:  TokenHerbz [ Thu Apr 27, 2006 6:56 pm ]
Post subject: 

OOO SEXY!!!! A chance to write something confusing again!!!

Here is MY vertion... I FORBID you from taking my overly complex code

code:

%%my vertion:  I tryed to make it as complex and confusing as i could just to tease you :)

%%the users input:
var answer : string
%%im not even going to add your * border cause you do it sloppy.

var question : array 1 .. 7 of string  %%i like arrays!
question (1) := "Can you reach the end of this program?"
question (2) := "Are you sure about that?"
question (3) := "Is there a point to this program?"
question (4) := "There is, to make you LOSE!, so you HATE games?"
question (5) := "Are you hugly obese?"
question (6) := "TRICK:  Are you older then 50?"
question (7) := "Do you lie??"

%%a function to make things look cooler :)
fcn answer_question : string
    loop
        put "'Yes' or 'No': " ..  %%output questions
        get answer  %%get answer
        exit when answer = "yes" or answer = "no"   %%exit with anwer
        put "please answer with a 'Yes' or 'No' only please."   %%displays the users stupid and can follow directions :P
    end loop
    result answer  %%results the answer
end answer_question

loop
    for i : 1 .. 7
        put question (i)
        answer := answer_question
        %%exit on 7 no matter what.
        if i = 7 then
            put "YOU LIE, LIAR Mc LIE LIE!!!!"
            exit
        end if
        if i = 1 or i = 2 or i = 3 or i = 6 then
            exit when answer = "no"
        else
            exit when answer = "yes"
        end if
    end for
    exit
end loop
put "I knew you would lose because your a failure!"


Award Token bits?? Smile

Author:  do_pete [ Thu Apr 27, 2006 9:43 pm ]
Post subject: 

You don't need the exit after "if i = 0 then" because it exits anyway since it's the 7th time around the loop

Author:  do_pete [ Thu Apr 27, 2006 9:46 pm ]
Post subject: 

Oops, I meant to say 7 not 0 Embarassed

Author:  kickflipto50-50tobigspin [ Thu Apr 27, 2006 11:40 pm ]
Post subject: 

Wow you guess confused me like crazy, just trying to read it and understand you high tech Turing mumbo jumbo. I think I was able to understand HellblazerX the best. I would do it your way but then I don't know how to get the next question to pop up. For example if the User types in yes the program will not exit but but I have no idea to make the next question pop up, I only now if so so then put" so and so" . Crying or Very sad I should I learned the basics Crying or Very sad .


: