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

+1

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.. https://code.sololearn.com/c2V8P8hG4ad1/?ref=app

1/14/2021 3:46:09 AM

๐ŸVolley

3 Answers

New Answer

+2

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; }

+2

Thank u sooo much Elizabeth Kelly ๐Ÿ˜๐Ÿ˜

0

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