Programming Step 1
Think about how you would solve the problem without a computer program
- The program is supposed to calculate the number of grams for three sets of pounds and ounces. We need a formula to do the calculation. The formula is a mathematical model for the conversion between two measurement systems. Computers are great at doing calculations with numbers, so we must reduce the problem to some mathematical model which the computer can solve. If you do not know how to solve the problem by hand, then you can not tell the computer how to solve the problem using a program.
- Since there are 454 grams in a pound, and 28.35 grams in an ounce (avoirdupois weight), the conversion formula would be
- weight in grams = pounds x 454 + ounces x 28.35