While training, a cyclist rides the same road to and from. Now his distance controller is not working: there is an error in the controller code, and the road back is calculated incorrectly.
The variable distance contains the last distance traveled in one direction. If the cyclist is riding back, the distance variable must be negative. To calculate the total distance traveled, the negative distance must be inverted and then added to the totalDistance variable. However, for some reason, the code does not work now.
Fix the code below to make it work.