0

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)

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by pty
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.