954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

delphi task

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)

spargelsuppe
Newbie Poster
1 post since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

wow kool

eric923456
Newbie Poster
13 posts since Oct 2005
Reputation Points: 10
Solved Threads: 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

pty
Posting Pro
530 posts since Oct 2005
Reputation Points: 64
Solved Threads: 39
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You