Computer Science Canada Adding array variables together. |
Author: | Brendon [ Sat Jan 12, 2008 7:26 pm ] | ||
Post subject: | Adding array variables together. | ||
First post Anyways, I got kicked out of school, and thus I have to continue my computer tech course at home. Im having trouble getting these array's to add up. Where I have put the "?????" I dont know the line of code to have it add up all the values in the array. Before I did it, without the array by simply sub:=total(x) + total(x) ect for the number of values there were. Now, with the sentenial loop where there could be any amount of "total(x)" variables, I am unsure of how you would make the command to add them up. I hope you follow my question. Here is my code. I have highlighted the line I am unsure of in bold. Any help is GREATLY appreciated.
|
Author: | Tony [ Sat Jan 12, 2008 7:31 pm ] |
Post subject: | RE:Adding array variables together. |
if you know how many element you have in an array so far (with a use of a counter variable, for example), you could use a for-loop to go through all of those variables. |
Author: | Clayton [ Sat Jan 12, 2008 7:53 pm ] |
Post subject: | RE:Adding array variables together. |
Also, GST has gone down 1% |
Author: | StealthArcher [ Sat Jan 12, 2008 8:36 pm ] |
Post subject: | RE:Adding array variables together. |
For Great Justice. But yeah, for loop, set up to add the values is best, for a challenge, make it caluculate if each object gets charged either type of tax, and have it calculate it in that foor loop, item by item. |
Author: | Brendon [ Sat Jan 12, 2008 9:33 pm ] |
Post subject: | RE:Adding array variables together. |
I have never done anything like this before....would anyone mind editing the source so it works? im sorry, im not all that great with turing. |
Author: | StealthArcher [ Sat Jan 12, 2008 9:35 pm ] |
Post subject: | RE:Adding array variables together. |
We don't do work for you here. If it's my query that gets you, think about multidimensional arrays, make another 2 dimensions for pst applicable and gst applicable, then as each items price is checked, check for pst/gst applicability, and add it to the item's price, then add the total to the main total. |
Author: | Tony [ Sat Jan 12, 2008 10:19 pm ] | ||
Post subject: | Re: RE:Adding array variables together. | ||
Brendon @ Sat Jan 12, 2008 9:33 pm wrote: would anyone mind editing the source so it works?
That is against forum's policy. You are better of figuring this out on your own anyway, it's not difficult
|