Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Write a test program that invokes these functions to display the following tables

Pounds Ounces| Ounces  Pounds
11   176     | 1      0.0625
2   192      | 2      0.125
...
9   304      | 9      0.5625
0   320      | 10     0.625


What I have tried:

C++
// Convert from pounds to ounces
double poundsToOunces(double pounds)
// Convert from ounces to pounds
double ouncesToPounds(double inches)
 The formula for the conversion is
pound = 16 * ounces
celsius = 0.0625 * pound
Posted
Updated 7-Nov-20 19:59pm
v7
Comments
Rick York 7-Nov-20 18:58pm    
You are almost there. Keep going.

Very interesting. I have never seen a conversion from pounds to degrees. I don't think the units correlate there.

First, I recommend that you choose ONE language.
Patrice T 7-Nov-20 19:15pm    
What is the question ?
[no name] 7-Nov-20 20:29pm    
Is this for a flight control system? Besides your ounces and pounds, you also got your inches and your (degrees) celsius.
jeron1 9-Nov-20 10:07am    
 pound = 16 * ounces 
So if you have 1 ounce, that equates to 16 pounds?
merano99 31-Oct-22 18:15pm    
According to the table above, it should be 1/16. Other entries in the table are probably nonsense.

1 solution

So little code, so many errors ...
C++
// Convert from pounds to ounces
double poundsToOunces(double pounds)
// Convert from ounces to pounds
double ouncesToPounds(double inches)
What is the conversion rate from Inches to Pounds?
For that matter, how does one convert from a weight to a temperature? Even in Metric units which are designed to be properly interrelated, there is no specific conversion factor.

Use names that describe what the variable contains: "inches" means the reader expects to provide a length, not a weight.

Comments should provide additional information, not describe exactly what the code is already saying.

C++
double poundsToOunces(double pounds)
   {
   return ... converted value ...
   }

double ouncesToPounds(double ounces)
   {
   return ... converted value ...
   }
I'll let you "fill in the blanks" and convert the actual value.
Then all you have to do is write some test code in your main function to call those functions with the values in the question and print the results.
Depending on the language you are using, you will want to look at Input/output manipulators[^] for C++, or Formatting Numeric Print Output[^] for Java.
 
Share this answer
 
Comments
CPallini 9-Nov-20 2:28am    
5.'Pound' to 'Celsius' is, well... Innovative!
OriginalGriff 9-Nov-20 2:51am    
Things do get heavier when they get hotter - I find them a lot harder to hold onto when I take them out of the oven ... :laugh:

In fact, they should be heavier when you heat them up - you are increasing the energy in they object after all, and E=mc^2
Probably not a measurable difference though!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900