Computer Science Canada Help with a simple class project |
Author: | ecookman [ Tue Oct 14, 2008 10:48 am ] |
Post subject: | Help with a simple class project |
i am trying to set a if statement to get the program to loop if the user types yes... here is what i have so far var yesno : string var m1 : real var m2 : real var m3 : real var m4 : real var m5 : real var t1 : real var t2 : real var t3 : real var t4 : real var t5 : real loop put "what was your first mark?" get m1 put "what was the first test out of?" get t1 put "what was your second mark?" get m2 put "what was the second test out of?" get t2 put "what was your third mark?" get m3 put "what was the third test out of?" get t3 put "what was your fourth mark?" get m4 put "what was the fourth test out of?" get t4 put "what was your fifth mark?" get m5 put "what was the fifth test out of?" get t5 cls put "the total score of all the tests is, ", m1+m2+m3+m4+m5, " out of, ", t1+t2+t3+t4+t5 put "therefore the total mark average wise is, " .. put round((((m1/t1)+(m2/t2)+(m3/t3)+(m4/t4)+(m5/t5))/5)*100), "%" put "would you like to do this again" get yesno if (yesno="yes") then %this where i want it to restart thanks fo the help -ecookman ![]() |
Author: | ecookman [ Tue Oct 14, 2008 10:51 am ] |
Post subject: | Re: Help with a simple class project |
darn it srry for this but i forgot something i am pretty fluent in programming languages i am a newbie to this forun(really like it) but i am not a newbie at prigramming i know advanced functions of .bat and .vb i even take programming cources and fun outside of school clases where i make games... so just lay it on me i might not understand at first (turing is new to me ) but i'll fighre it out _^_^ |
Author: | Insectoid [ Tue Oct 14, 2008 11:18 am ] | ||||
Post subject: | RE:Help with a simple class project | ||||
You need to put a big loop around everything, then use an 'exit when' statement. Eg.
In if statements in Turing, you don't need brackets. so
And please, work on your spelling. It is difficult to decifer a sentance in a sea of typoes. |
Author: | S_Grimm [ Tue Oct 14, 2008 11:29 am ] |
Post subject: | RE:Help with a simple class project |
Deletia but insectoid is right. a giant loop would be the only way. just stick the variable declarations (var a : real) OUTSIDE the loop. |
Author: | Sean [ Tue Oct 14, 2008 11:38 am ] | ||||
Post subject: | Re: Help with a simple class project | ||||
Also, to make life simpler, and your code more clean, you can declare similar variables on the same line:
And since you are asking for it to restart, yes or no, do what Insectoid said. Create the loop, check the variable, if it continues clear the screen and restart. To clear the screen use the command cls.
|
Author: | ecookman [ Tue Oct 14, 2008 3:42 pm ] |
Post subject: | Re: Help with a simple class project |
Thank you all and sorry for selling errors. I very quickly typed this before i had to go back to class ![]() |