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.
Can someone please fix it up for me so it cna run and post it back here? |
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: | |||
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:
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
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.
|
Author: | kickflipto50-50tobigspin [ Wed Apr 26, 2006 8:35 pm ] | ||
Post subject: | |||
Okay this is the part that is wrong
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? |
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.
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
It still doesn't work. |
Author: | Clayton [ Wed Apr 26, 2006 9:09 pm ] | ||
Post subject: | |||
thats because turing doesnt end like this
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
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: | |||
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.
|
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.
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
"\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 :
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
Award Token bits?? |
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 |
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" . I should I learned the basics . |