Computer Science Canada Two program problems |
Author: | hugonibs2 [ Wed Apr 22, 2009 8:32 am ] | ||
Post subject: | Two program problems | ||
What is it you are trying to achieve? I am trying to create a program that will sort the players into weight catagories. What is the problem you are having? I have two problems in this program. The first I would like to loop it with the variable that is entered in players. Is this possible? the second problem how would i fix this line if 60 < weight < 80 then I would like for it to choose this statement if the weight is bigger than 60 but less then 80.
Please specify what version of Turing you are using 4.1 |
Author: | BigBear [ Wed Apr 22, 2009 1:44 pm ] | ||||
Post subject: | RE:Two program problems | ||||
Must be
Also to get a variable in a loop you need to declare the variable outside the loop and then just use the get command Calling a variable in a loop is bad coding because it creates a variable every time and you can no longer access the previous variables created so they are useless. Also if you want to check the value of the variable it can be nothing. |
Author: | hugonibs2 [ Thu Apr 23, 2009 7:16 am ] |
Post subject: | RE:Two program problems |
Do you know if i is possible for me to loop according to the number that is entered in players |
Author: | TheGuardian001 [ Thu Apr 23, 2009 3:28 pm ] | ||||
Post subject: | Re: Two program problems | ||||
I believe you are looking for for loops a for loop will take a section of code and run it a specified number of times.
it's basically a short way of doing this:
i can be replaced with anything you want, as long as it is not already being used. It's just a temporary variable. 1 .. 10 you can use integers or variables for these two values. it basically just tells Turing how many times to run a section of code. this one runs 10 time. |
Author: | tjmoore1993 [ Thu Apr 23, 2009 7:55 pm ] | ||||
Post subject: | RE:Two program problems | ||||
I excluded the following code from the project.
You did not give a specific purpose for this so I decided to remove it. |