Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Quiz program - elsifs and loops problems
Index -> Programming, Turing -> Turing Help
Goto page 1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kickflipto50-50tobigspin




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Wed Apr 26, 2006 7:48 pm   Post subject: (No 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.
kickflipto50-50tobigspin




PostPosted: Wed Apr 26, 2006 7:55 pm   Post subject: (No 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.
Cervantes




PostPosted: Wed Apr 26, 2006 8:05 pm   Post subject: (No 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.
kickflipto50-50tobigspin




PostPosted: Wed Apr 26, 2006 8:10 pm   Post subject: (No 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.
Clayton




PostPosted: Wed Apr 26, 2006 8:12 pm   Post subject: (No 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
kickflipto50-50tobigspin




PostPosted: Wed Apr 26, 2006 8:17 pm   Post subject: (No 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?
Clayton




PostPosted: Wed Apr 26, 2006 8:31 pm   Post subject: (No 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
Sponsor
Sponsor
Sponsor
sponsor
kickflipto50-50tobigspin




PostPosted: Wed Apr 26, 2006 8:35 pm   Post subject: (No 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.
kickflipto50-50tobigspin




PostPosted: Wed Apr 26, 2006 8:36 pm   Post subject: (No subject)

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




PostPosted: Wed Apr 26, 2006 8:38 pm   Post subject: (No subject)

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




PostPosted: Wed Apr 26, 2006 8:39 pm   Post subject: (No 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.
HellblazerX




PostPosted: Wed Apr 26, 2006 8:42 pm   Post subject: (No 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.
Clayton




PostPosted: Wed Apr 26, 2006 8:42 pm   Post subject: (No subject)

put in another one, you might still be missing one
kickflipto50-50tobigspin




PostPosted: Wed Apr 26, 2006 8:46 pm   Post subject: (No 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 3  [ 34 Posts ]
Goto page 1, 2, 3  Next
Jump to:   


Style:  
Search: