Thursday, July 30, 2009

I need help with C++ Function in an array?

I need to create an array and one thing I can't figure out is the function to make it work. The calculation to determine the cost of the package is [basic overhead charge] + [the cost of the package weight] * [the factor for the zone]. I can add the code if anyone can help me. Thanks!

I need help with C++ Function in an array?
What is the problem then?


http://ronaldborla.blogsome.com/
Reply:Yes, please add the code. Or at least give us a better idea of the algorithm you are using. Are you trying to create an array where each element is determined by that formula?





If you do say more I promise to check back and edit this.





I promised to edit this. I'm very tired, but, which is the array, the cost of the package, the cost of mailing the package to each zone or both?





It seems to me each line of the table would be package weight, cost of mailing the package to each zone then a new line. therefore the formula would be [basic overhead charge]+ [cost of the package weight[array subscript]]*[factor for the zone[arraysubscript}].





Except, you could run the function so it takes the package weight and the cost of the package weight as variables, that is figure that outside the function. Then it would be:


if


.


.


.


CHARGE=basic overhead charge


Weight=cost of the package weight


Zone[ARRAYSIZE]= factor for the zone


cout %26lt;%26lt; PackageWeight;


for (j=0;j%26lt;ARRAYSIZE;j+=1)


{


cout %26lt;%26lt; '\t';


cout %26lt;%26lt; CHARGE+Weight*Zone[j];


}


cout %26lt;%26lt; endl;





where of course '\t' is the symbol for tab because I'm really just a tired old c programmer. It should print out eight blank spaces.





I know of places where you can paste any text file you wwant for up to a week, but I don't remember any addresses, sorry. You might consider asking this in one of the C programming news groups. They're still around.

columbine

No comments:

Post a Comment