Metric tons program

I know this form says no home work aloud but I need help I can't figure this out. The program I'm trying to make is that it need to prompt the user to enter the amount of rice, in pounds a bag can hold. The program needs to out put the number of bags needed to store one metric ton of rice . One metric time is 2,205 lb
Something like:
int lbs;
cout << "Enter the amount of rice a bag can hold: ";
cin >> lbs;
// Do your conversion & print 
Last edited on
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?
Last edited on
@hengry that's correct
Last edited on
mbozzi no it's not
I'm just confused how do I put all that into a program
What are you confused about? It's a user input and printing out computation.

Here's an example of inches to centimeters:
#include <iostream>

int main()
   float inches; // float if it's not a whole number
   std::cout << "How many inches are you trying to convert to centimeters? ";
   std::cin >> inches;
   std::cout << inches << " inches is equivalent to " << inches * 2.54 << " centimeters.";
Last edited on
Topic archived. No new replies allowed.