two script in below should give same result but they differ please help (they are all problem set 1b) the first one is http://codepad.org/RpFe5DMe and the second one is http://codepad.org/4iGO9ImD the second one is correct what should i do to make the first one to bring same result as the second please help
Hello, there. It seems you need to incrementally increase minpay until the conditions are met.
the minpay increases in the outer most loop after the inner loop is done with all the iterations . sot the minpay increase
Got it. That's very clever how you have that. I notice that the sample solution uses a while loop, then increments minpay until the balance is not greater than zero. Is there a way you can do that with your for loops? I have found that using print statements can be a great way to see how what your code is doing while it's performing an exhaustive search.
try this http://codepad.org/qeh8theT maybe you can see what is happening. at the bottom of the outer loop you need to reset the balance to the original balance that was entered by the user
thanks for reply you code brings the same result as my code which defer with the sample solution
my code was your code with some print statements inserted. the result of those print statements should let you see what is happening when your code runs so that you can form a hypotheses for what is going wrong and attempt a correction. it is my opinion that at the bottom of the outer loop you need to reset the balance to the original balance that was entered by the user.
thanks for your reply i have seen the point to reset to the balance to the original balance i have tried and it is not working .this is what i have tried http://codepad.org/YsQduSRb
thanks a lot bwCA
Join our real-time social learning platform and learn together with your friends!