Conversion cm/m | Sololearn: Learn to code for FREE!


Conversion cm/m

All the coding is right, when when I convert it to cm or m it doesn't give the right ams. Why..

1/14/2021 3:46:09 AM


3 Answers

New Answer


It is because you are performing the opposite conversion in the methods you are using to return the converted value. Essentially, you are converting the number, but then converting it back to its original value. Change lines 17 and 19 to just return d; This will correct the issue. Lines 17-21: double length::cm() { return d; } void length::cm(double x) { d = x/100; } double length::meters() { return d; } void length::meters(double x) { d = x/100; }


Thank u sooo much Elizabeth Kelly 😍😍


Glad to help. Please mark the answer as correct/best if it successfully resolves the issue :)