Thank you so much for the help once again. I can't thank you enough.
There are two things that I don't understand thought.
1 2 3 4
|
grams = 1000 * (kilograms - int(kilograms));
//grams = 1000 * (4.67768 - 4)
kilograms = int(kilograms);
//kilograms = 4
|
I've heard of static casting before, so I'm guessing typecasting is similar.
I can kind of see what is being done here. If there is 4 kilograms we are subtracting 4 from kilograms to leave the 0.67768 number and then we are multiplying that by 1000 to get the grams. I also didn't know you can typecast like that. I figured with static casting you'd have to do
static_cast<double>kilograms - int (kilograms);
Or something similar to that.
So I learned how to typecast. Thank you :]
When I enter 10 pounds and 5 ounces, I output
4 kg, 602.562 grams.
Which I looked on google that 10 pounds is about 4 kg so that is correct... But am not sure about the grams calculation.
Second,
pounds = pounds + ounces / 16;
Does this cover all I need to calculate for pounds and ounces in my
weightCalculating
function? Or do I need to have a calculation for ounces as well?
Again, I appreciate your help. After I understand this problem, I have a very similar problem that has to deal with length instead of weight, so I'm looking forward to using this as a reference to figuring out how to do my length program.