Hi there,
I need help :o ... I have to solve the following task, a person buys goods and everytime the person receives change. The aim is that the person has as few as possible coins in its wallet. The person has an unlimited value of one dollar coins. And at the beginning 5 1 cent coint, 5 2 cent coins, 5 5 cent coins, 5 10 cent coins, 5 20 cent coins and 5 fifty cent coins in his wallet. I shall simulate as many times as the programs user wants an amount the person has to pay (between 0.05\$ and 30.00\$). The program shall return which coins I shall give to the cashier (for each amount). The cashier always gives as few small change as possible. The person has everytime enough 1\$-coins (or notes) and only wants to have as few 1cent,2cent,5cent,10cent,20cent,50cent coins as possible in his wallet. I don’t really know how I shall solve that I would be very nice if you try to help me…
It should be programmed with Delphi (5or7)

wow kool

Hi there,
I need help :o ... I have to solve the following task, a person buys goods and everytime the person receives change. The aim is that the person has as few as possible coins in its wallet. The person has an unlimited value of one dollar coins. And at the beginning 5 1 cent coint, 5 2 cent coins, 5 5 cent coins, 5 10 cent coins, 5 20 cent coins and 5 fifty cent coins in his wallet. I shall simulate as many times as the programs user wants an amount the person has to pay (between 0.05\$ and 30.00\$). The program shall return which coins I shall give to the cashier (for each amount). The cashier always gives as few small change as possible. The person has everytime enough 1\$-coins (or notes) and only wants to have as few 1cent,2cent,5cent,10cent,20cent,50cent coins as possible in his wallet. I don’t really know how I shall solve that I would be very nice if you try to help me…
It should be programmed with Delphi (5or7)

your description confused me, but would it not make sense to loop through each coin in descending order increasing the quantity until the value is the coin's value less than the total? so for example if you want £3.51 change it will loop through 3 £1 coins, 1 50p, 0 20p, 0 10p, 0 5p, 0 2p and 1 1p

Be a part of the DaniWeb community

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