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

Username:   Password: 
 RegisterRegister   
 Mah First Program Evar!
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mattlap




PostPosted: 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



Program.t
 Description:

Download
 Filename:  Program.t
 Filesize:  4.86 KB
 Downloaded:  249 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Fri Apr 29, 2011 6:40 pm   Post subject: RE:Mah First Program Evar!

Turing:

if how = "good" then
   put "Well that's always nice."
elsif how = "Good" then
   put "Well that's always nice."
elsif how = "bad"

you can add an "or" instead
Turing:

if how = "good" or how = "Good" then
        put "Well that's always nice."


This is confusing:
Turing:

if age = age
if movie = movie

Pretty redundant, it'll always equal itself Razz
Also, I would add white spaces inbetween sections of code, it's easier on the eyes that way.
Other than that, not too bad.
mirhagk




PostPosted: 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:
Turing:

if upper("Hello")="hello"
 put "hi"
endif
Raknarg




PostPosted: 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:
Turing:

if Str.Upper (word) = "YES" then ...

almost the same Razz
mirhagk




PostPosted: 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
Mattlap




PostPosted: Fri Apr 29, 2011 6:54 pm   Post subject: Re: Mah First Program Evar!

Thanks Smile . The only reason I put the "if age = age" and "if movie = movie" is because I didn't know what do do there because there could be a multitude of responses that aren't Marven (if that makes sense). My friend told me to do the "Marven" as answers business because he thought it would be funny but i didn't know what to do if the response wasn't "marven". Like at the age part, if they answered 14 instead of Marven, it would just restart the program and i didn't know what else to do. If you have a solusion to that problem I'd love it Smile

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
mirhagk




PostPosted: 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
Turing:

if age=age

into
Turing:

else
Mattlap




PostPosted: Fri Apr 29, 2011 7:06 pm   Post subject: Re: Mah First Program Evar!

So this is what I did :

Turing:


put "First question: 'How old are you?'" %Fourth Question
        get age
        if age = "Marven"
                then
            put "STOP SAYING THAT!!!!"
        else %This used to be elsif age = age
            put "Well, ", age, " isn't very old compared to me."
            randint (mine, 1, 123455)



But if I put in Marven for the age variable it just starts the program over. not sure what to do.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: 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?
Mattlap




PostPosted: 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 Smile.

-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?
Raknarg




PostPosted: 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 Razz

Oh, so you DO want it to end when the program says "Stop saying that!"?
Mattlap




PostPosted: 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 Smile

I'm going to be back in like an hour so no hurry to respond lol
Raknarg




PostPosted: Fri Apr 29, 2011 8:24 pm   Post subject: Re: Mah First Program Evar!

You move the end if.
Turing:

if age = "Marven" then
     put "STOP SAYING THAT!!!!"
elsif age = age then
     put "Well, ", age, " isn't very old compared to me."
     randint (mine, 1, 123455)
     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."
     colour (45)
     colourback (59)
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:
Turing:

%age question
if age = marven then
     stuff
else
     stuff
     %movie question
     if movie = marven then
          stuff
     else
          stuff
          %Royal Wedding question

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
Mattlap




PostPosted: 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! Smile. Just for that you can have 1/11 of my bits lol. Thanks again for spending your time to help out a very ignorant beginner Smile


-Matt
Raknarg




PostPosted: Fri Apr 29, 2011 10:09 pm   Post subject: RE:Mah First Program Evar!

No probs Wink Come back if you have other questions.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 15 Posts ]
Jump to:   


Style:  
Search: