The program needs to out put the number of bags needed to store one metric ton of rice . One metric tonne is 2,205 lb |
Work it out on paper first.
Let n be the number of bags required.
Let x be the number of pounds of rice which a single bag holds.
If each bag is equivalent to x pounds of rice, then the ratio
1 bag / x lbs rice = 1. This is our first conversion factor.
Similarly, if one tonne is 2205 lbs, then the ratio
2205 lbs / 1 tonne = 1. Because these ratios differ only in units, we can multiply and divide them to perform the conversion:
x bags = (1 bag / x lbs rice) * (2205 lbs / 1 tonne) * 1 tonne
If you perform the multiplication, you'll notice that the result is dimensionally correct: i.e, when you simplify it, the result is in units of bags:
n bag = (1 bag / x lbs rice) * (2205 lbs rice / 1 tonne) * 1 tonne = (2205 / x) bags = n bags
We can't request fractional bags, so you would round this quantity upwards to the nearest integer, using std::ceil.
Are you sure your other question isn't another dimensional conversion problem?
http://www.cplusplus.com/forum/general/220850/