15,741,692 members
See more:
Implement a function that when called returns Stopping Distance.
Formula for stopping distance is
Stopping Distance = (v × t) + { v² / [2 × g × ( f±G )] }
Where, g = gravity (9.8)
v = Vehicle Speed
t = perception Time
f= Coefficient of Friction
for Uphill (Stopping Distance = (v × t) + { v² / [2 × g × ( f+G )] } )
for Downhill (Stopping Distance = (v × t) + { v² / [2 × g × ( f - G )] } )
When the function is called, it asks the values of above mentioned variables and returns the stopping distance.

What I have tried:

it is impossible for me to write code
Posted
Updated 26-May-16 20:51pm

## Solution 1

Quote:
it is impossible for me to write code
This is real basic HomeWork. If 'it is impossible for you to write code' you have big problem.

## Solution 2

"it is impossible for me to write code"
Then you are on the wrong course, and you will fail it.

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
And we certainly aren't going to cheat you through a course you have no intention of trying to pass yourself. That wouldn't be fair on the rest of your class, or anyone who might employ you on the basis of your pass.

## Solution 3

I show you a way to write a function for 'travel distance at constant speed'. I suppose it's just enough to make you figure out how to write the requested one.
```Travel distance at constant speed = (v x t)
v = constant vehicle speed
t = elapsed time.```

C++
```double travel_distance(double v, double t)
{
double distance = v * t;
return distance;
}```