Computer Science Canada Mah First Program Evar! |
Author: | Mattlap [ Fri Apr 29, 2011 6:21 pm ] |
Post subject: | Mah First Program Evar! |
So yeah, this is for a grade nine computer tech project. Again, first project ever, so any CONSTRUCTIVE criticism would be greatly appreciated XD. What this is, is just a simple quiz (the assignment was to make a program that asked 10 questions). -Matt |
Author: | Raknarg [ Fri Apr 29, 2011 6:40 pm ] | ||||||
Post subject: | RE:Mah First Program Evar! | ||||||
you can add an "or" instead
This is confusing:
Pretty redundant, it'll always equal itself ![]() Also, I would add white spaces inbetween sections of code, it's easier on the eyes that way. Other than that, not too bad. |
Author: | mirhagk [ Fri Apr 29, 2011 6:47 pm ] | ||
Post subject: | RE:Mah First Program Evar! | ||
Not bad at all for your first program, I can tell from your programming style that your gonna be good at this. Just wanted to point out a few tips: First of all, checking age=age, well that will always be the case, so instead of an elsif, just use else Second, Turing let's you convert a string to all upper or lower case letters (just wrap the string with upper() or lower() like so:
|
Author: | Raknarg [ Fri Apr 29, 2011 6:51 pm ] | ||
Post subject: | RE:Mah First Program Evar! | ||
Actually, that's a different function, that would ouput 5, not HELLO. the right syntax:
almost the same ![]() |
Author: | mirhagk [ Fri Apr 29, 2011 6:54 pm ] |
Post subject: | RE:Mah First Program Evar! |
lol sorry, been a long time since I worked with turing, so I just opened up a turing window and said the first thing that colored back |
Author: | Mattlap [ Fri Apr 29, 2011 6:54 pm ] |
Post subject: | Re: Mah First Program Evar! |
Thanks ![]() ![]() EDIT: This is all at Raknarg By the way EDIT 2: I'm not sure I follow, Raknarg, this my first time using Turing and I kind of need some explanations lol |
Author: | mirhagk [ Fri Apr 29, 2011 6:58 pm ] | ||||
Post subject: | RE:Mah First Program Evar! | ||||
just use else instead of elsif, and then continue with your outputting their age and stuff, the only line that changes is
into
|
Author: | Mattlap [ Fri Apr 29, 2011 7:06 pm ] | ||
Post subject: | Re: Mah First Program Evar! | ||
So this is what I did :
But if I put in Marven for the age variable it just starts the program over. not sure what to do. |
Author: | Raknarg [ Fri Apr 29, 2011 7:17 pm ] |
Post subject: | RE:Mah First Program Evar! |
Yes, that would be because of the setup. if age = Marven then stuff else rest of the program end if That's essentially how yours is set up. What you need to have is a nested if instead have the end if way before. if age = Marven then stuff else stuff end if rest of the program Get it? |
Author: | Mattlap [ Fri Apr 29, 2011 7:32 pm ] |
Post subject: | Re: Mah First Program Evar! |
I understand now. Thank you so much for helping me with this! You have my gratefulness and if I had 25 posts you'd also have +1 karma lol. Thanks again ![]() -Matt EDIT: One last question (unless you feel as though you've wasted enough time with me already lol), how would I make it so that at the age part, when you type in Marven it just says "stop saying that" and not that other stuff? |
Author: | Raknarg [ Fri Apr 29, 2011 7:51 pm ] |
Post subject: | RE:Mah First Program Evar! |
Don't worry about wastimg my time, I do this for fun ![]() Oh, so you DO want it to end when the program says "Stop saying that!"? |
Author: | Mattlap [ Fri Apr 29, 2011 8:01 pm ] |
Post subject: | Re: Mah First Program Evar! |
I want it to skip the " put "How old am I? Well, let me think." delay (1200) put "It's been a while since I thought about this." delay (1000) put "I'm, hmmm." delay (500) put "I've got it!", "I'm ", mine, " human years old." part but i don't know how lol. If you could help me out with that it would be great ![]() I'm going to be back in like an hour so no hurry to respond lol |
Author: | Raknarg [ Fri Apr 29, 2011 8:24 pm ] | ||||
Post subject: | Re: Mah First Program Evar! | ||||
You move the end if.
See, what the issue is for the age and movie question is that if you say the answer is marven, it'll skip all the code that would normally happened. Like it only reached those if statements when you dont input marven. The solution is as I said; Take the end ifs you had at the end and move them back to their original ifs. Dont use nested ifs unless you mean to. When I say nested ifs, I mean this:
You should take them out of those if statements and have them separate. Btw, as useless and stupid as the Royal Wedding was, 2 billion people at least still watched it ;P |
Author: | Mattlap [ Fri Apr 29, 2011 9:49 pm ] |
Post subject: | Re: Mah First Program Evar! |
Raknarg @ Fri Apr 29, 2011 8:24 pm wrote: Btw, as useless and stupid as the Royal Wedding was, 2 billion people at least still watched it ;P
I'm only 14 so I belong to the approx. 2/3 of the world's population that doesn't watch it XD Also thanks so much (again lol)! I just did what you said and (no surprise you genius, you) it worked! ![]() ![]() -Matt |
Author: | Raknarg [ Fri Apr 29, 2011 10:09 pm ] |
Post subject: | RE:Mah First Program Evar! |
No probs ![]() |