Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hi all,

Develop an algorithm in C# to give exact change(money) for a Purchase.
INDIAN RUPEES.
The Input is the Change in Rupees.
The Output is the number of Coins & Notes.
Assume that the Coins are Re.1,Rs.2.
The Notes are 5,10,20,50,100,500,1000.Which are our Indian Rupee notes.

Please help on this issue

Thanks in advance

S.Naveen...
Posted
Updated 23-Sep-10 12:22pm
v2
Comments
Dylan Morley 22-Sep-10 11:31am    
Homework
Smithers-Jones 22-Sep-10 11:32am    
Lazy bum.
Sandeep Mewara 22-Sep-10 12:55pm    
Why don't you put some effort from your side?
Sandeep Mewara 22-Sep-10 12:55pm    
Here is what is expected by enquirers:
1. TRY first what you want to do!
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.
nav234 23-Sep-10 1:38am    
Hi all,
i am really sorry ,actually i don't know how to begin with,an array or collections or something else.i simple started writing with for loops and got inputs but not having any idea on how to proceed in code .

1 solution

This is a real beginner type question.
Your algorithm will require that you start with the highest value note.

you will need a loop of some sort. Divide the amount outstanding by the note valid e.g 1500 / 1000 = 1.5 therefore you requre 1 x 1000 note.
The remained (0.5) is multiplied by 100 giving your 500. Divide that by 500 e.g 500 / 500 = 1 therefore you require 1 x 500 note.

Final result is you will need 1 x 1000 note and 1 x 500 note.
 
Share this answer
 
Comments
nav234 23-Sep-10 1:39am    
thanks Steven ,but i am struggling to implement these logics in C#.Okay try my best...
Toli Cuturicu 23-Sep-10 18:24pm    
We don't simply provide you free easy code.
We explain or correct your code. We give hints and spot errors.
Okay?

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