Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My lecturer asked me to write code about converting the Money to Note for example I have 187 dollars so it equals to 1 one hundred dollar note,1 fifty dollars note,1 twenty dollars note,1 ten dollars note,1 five dollars note and 2 one dollars note.Please help me because i've just learned this subject for 2 weeks!!!Thanks in advance!!!
Posted
Updated 15-Jan-12 14:42pm
v4
Comments
OriginalGriff 15-Jan-12 11:19am    
And what is your problem?
It's not too difficult, so how far have you got?

My suggestion is to think about how you solved it in your mind, and then translate that into an algorithm. Think about the things you know to be true - like the denomination of notes available to you - and then ask yourself some questions. For example, do you have to solve it with the minimum number of notes, how are you going to store note denominations, what interface will you use for input and output. Also, think about the mathematical issues. And how will you handle the situation where the user may not do what you expect, eg. enters $187.23?

Very nice exercise and please tell us how you get on. If you have any specific questions post back. Good luck!
 
Share this answer
 
Comments
Shahin Khorshidnia 15-Jan-12 13:00pm    
+5 for AnnieMacD.
Chandrasekharan P 16-Jan-12 2:55am    
Well explained. My 5
AnnieMacD gave you a clue in her answer above; this is just a question of simple mathematics.
Starting from your largest denomination note or coin see if the total is greater than that denomination, and if so subtract all values of that note from the total. Repeat the process for each denomination lower until your total reaches zero and your process is complete. Converting this small algorithm into C/C++ code should not be difficult even for a new student.
 
Share this answer
 
Comments
Albert Holguin 16-Jan-12 16:19pm    
+5 for the algorithm suggestion... not hard at all
Richard MacCutchan 17-Jan-12 3:17am    
Thanks, but it didn't require much brain power.
Albert Holguin 17-Jan-12 9:55am    
It didn't... but obviously the OP couldn't come up with it...lol

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900