Something weird in the code..?

Hi question about the code …
I noticed that in lines 36 37 if I do a inversion of the values ​​and put the cost value before the method value the result of the function creates a mistake answer … can someone please explain to me why …?

2 posts were merged into an existing topic: What wrong in the code? why dose it not find the function