Help with a simple class project
Author |
Message |
ecookman
![](http://compsci.ca/v3/uploads/user_avatars/5690458955648ca661c338.gif)
|
Posted: 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 ![Canada Canada](http://compsci.ca/v3/images/smiles/canada.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
ecookman
![](http://compsci.ca/v3/uploads/user_avatars/5690458955648ca661c338.gif)
|
Posted: 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 _^_^ |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: 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.
code: |
loop
%stuff
exit when yesno = "no"
end loop.
|
In if statements in Turing, you don't need brackets. so
code: |
if this > that then
%do stuff
end if
|
And please, work on your spelling. It is difficult to decifer a sentance in a sea of typoes. |
|
|
|
|
![](images/spacer.gif) |
S_Grimm
![](http://compsci.ca/v3/uploads/user_avatars/18926424384e6d86e5cf4d6.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Sean
![](http://compsci.ca/v3/uploads/user_avatars/47413941748406f441f83e.png)
|
Posted: 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:
Turing: |
var m1, m2, m3 : real
var t1, t2, t3 : real
|
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.
Turing: |
loop
%stuff
put "Choose (Y/N): "..
get choice
exit when choice = "Y"
cls
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
ecookman
![](http://compsci.ca/v3/uploads/user_avatars/5690458955648ca661c338.gif)
|
Posted: 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 ![Razz Razz](http://compsci.ca/v3/images/smiles/icon_razz.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|