What is wrong with my code? I have spent a long time trying to figure it out but I cannot any help would be appreciated. I just updated it.
1 Answer
ok first thing "change" should not be float. it should be an int. you want a rounded off figure and not a decimal value.
second thing, in all of your if and else if statements, change-- means change = change - 1. you want to subtract the value of the coin you are using which would be 25/10/5/1.
last thing, when you use if statement, only once will the value of highest coin get subtracted. You want to subtract the value of coin as long as the change is more than that value.
Hope you find it useful. Have a great day!
-
Thank you so much I tried it again but I am still getting errors.– user29371Commented Aug 19, 2020 at 19:22
-
you dont need for loop for print statement. because at the stage of printing, change would be 0 and there will be infinite loop as change = 0 and coin > 1 will always be true. Also one thing you dont need coins > 1 condition. what if change = 25cents... you will get only 1 coin and it wont get printed– HimanshiCommented Aug 19, 2020 at 19:44
-
I don't know what to do now. How do I get to print the final result then?– user29371Commented Aug 19, 2020 at 19:48
-