+ 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
3 RĂ©ponses
+ 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 :)