So I'm working on a project where you have those plastic adjustable compartment boxes, and you want to fill one of those compartments with a certain product. I want to figure out how many can fit instead said box.
At the most basic level, I could do.
public static int VolCalc(int mLength, int mWidth, int mHeight, out int mVol) { // Solve for product and compartment volume. mVol = mLength * mWidth * mHeight; return mVol; } public static int TotalCalc(int mPVol, int mBVol, out int mTot) { // Solve for # of times a product can fill the box. var pMultiply = 0; for (mTot = 0; pMultiply <= mBVol;) { mTot++; pMultiply = mPVol * mTot; } // Since I'm using integers, remove the last one to account for <=. mTot -= 1; return mTot; } [/CODE]
Would you consider this the best way to approach this problem?
Question
Kalint
Math time!
So I'm working on a project where you have those plastic adjustable compartment boxes, and you want to fill one of those compartments with a certain product. I want to figure out how many can fit instead said box.
At the most basic level, I could do.
Would you consider this the best way to approach this problem?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts