I am adding a feature to my program in which the user will have the ability to change their unit of measurement at any time, and have the program recalculate their input and output.
If the user inputs say, 20lbs for an item, then decides he wants to work in kilograms instead, he can select an option to do so at any time, and the program will recalculate his 20lb input to 9Kg. Then if he decides he'd rather work in ounces, it would convert that 9Kg to 320oz, so on and so forth.
What would be the most effective and efficient way to go about this? I've been racking my brain trying to figure out a way to have the correct formula be implemented.
Do all your calculations in standard units (or the units you prefer to work with).
Only the user interface needs to care about the unit conversions. The rest of the code does not need to worry about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With