Hi Dw

I've recently created an application in java on this post:www.daniweb.com/software-development/java/threads/458306/how-to-work-with-jpos and now I just want to improve this by enabling a feature of mixing the cash notes when dispensing the required amount. The machine has these bills notes: 10, 20, 50, 100, and 200 so now what I want let say a user chosen to withdrawal 4000 the program can mix all the bill notes to form the required amount, should there be any un-available bill note the program uses another bill notes let say it was suppose to make 100 with 10 which is 10x10 bill notes and now there are no more 10 on the ATM the program should then skip and uses 20 to form 100 which will be 20x5 and also use the 50, 100, 200 to make up to total of 4000 amount.

I have no clue nor idea on how to start this, a recommendation and assistance will be appreciated.

Thanks

One simple way is the use as many 200 as possible, then as many as 100 etc until what's left can be done in 10s. If you get this version working then it should be easy to upgrade to more complex "A.I." algorithms to give "desirable" mixes of notes

## All 3 Replies

One simple way is the use as many 200 as possible, then as many as 100 etc until what's left can be done in 10s. If you get this version working then it should be easy to upgrade to more complex "A.I." algorithms to give "desirable" mixes of notes

That's exactly what I'm trying to do to get as many 200s as possible and if for example the user choose to withdraw 1500 its can get up to seven 200s and one 100 to make up the 1500 and just incase the 200s are not available it can then move on maybe to use the 100s to make up the total. So how can I do this in codes.

Thank you

Obviously you were able to work out that 1500 can use 7 200's, then that the remainer was 100, which is one 100 note, so just code the method/formula you used to do that in your head!
If that's not clear, just create a few more sample cases like that and work them out with paper and pencil, wrting down all the calculations and intermediate results. Once you've done that you will know exactly what the required logic is - converting that to code is completely trivial, in any language.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.