I am working with arrays and I need to figure out how to get the minimum amount of change with 50, 20, 10, 5, 1, with two loops, and display the change in a horizontal row. I have my code below and I know that the calculation I have set up going into the "money" variable does not give the correct change. Is the solution gonna be a matter of finding the right calculation and the rest of the code is fine? Or, do I need more code to handle the values form the array?
Got it to work! If money = 1, then "while(money > bankNotes[element 4])" would never be true and the while loop would not be entered to give evaluation and print. So, I put ">=" inside the while loop and it solved the problem.
I am trying to understand how printing "bankNotes[count]" gives the correctly calculated change though? It seems that the money variable is the one holding calculations and the "bankNotes[count]" holds the incremented counter from 0 to 4 which corresponds to the value at each element. So, I thought printing "bankNotes[count]" would just display the values stored in the array.