+ 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

14th Jan 2021, 3:46 AM
🏐Volley
🏐Volley - avatar
3 Respostas
+ 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; }
14th Jan 2021, 6:12 AM
Elizabeth Kelly
Elizabeth Kelly - avatar
+ 2
Thank u sooo much Elizabeth Kelly 😍😍
14th Jan 2021, 6:15 AM
🏐Volley
🏐Volley - avatar
0
Glad to help. Please mark the answer as correct/best if it successfully resolves the issue :)
14th Jan 2021, 6:17 AM
Elizabeth Kelly
Elizabeth Kelly - avatar