Problem :- Write A C++ Program To Find Denomination Needed for A Given Amount Along With The Total Number of Notes .
Generally Notes are used in banks are given below in descending Order .Ii is dependent to country wise their are some country Denomination
INDIA ( Rupees ) USA ( Dollar ) INDIA ( Rupees )
( Before 8 Nov. 2016 ) ( Present ) ( Present )
1000 100 2000
500 50 500
100 20 100
50 10 50
20 5 20
10 2 10
5 1 5
2 2
1 1
Logic :- The Logic Behind we have to divide a money by Above Money lets take a example Suppose money is 16108 then follow the Step We are taking a example of Indian Currency In present
Step 1:- Then First we divide 16108 by 2000 then we get 8 ,2000 rs notes then go to step 2
Step 2:- After divide 2000 we get a remainder 108 The we know that 108 is not divisible by 500 so go to next step
Step 3:- Now divide 108 by 100 then we get 1 ,100 rs note now remainder is 8 go to next step
Step 4:- 8 is divisible by 50 and 20 nor 10 so we escape now go to next step
Step 5:- Now divide 8 by 5 we get a 1 ,5 rs notes and remainder is 3 so go to next step
Step 6:- Now divide 3 by 2 we get 1 ,2 rs notes and remainder is 1
so follow the next step
Step 7:- This is a Last step divide 1 by 1 we get zero remainder now print the total no of denomination needed and along with total no of count require to fulfill a requirement
So for 16108 You Need to
No.
8 * 2000 = 16000
1 * 100 = 100
1 * 5 = 5
1 * 2 = 2
1 * 1 = 1
Total =12 Notes For minimum Transaction
See Also :- C Program For Denomination of an Amount
Solution :-
Method 1 :- Denomination For Indian Rupees
#include<bits/stdc++.h>
using namespace std;
int main()
{
/*Program By Ghanendra Yadav
Visit http://www.programmingwithbasics.com/
*/
int amt, r2000=0, r500=0, r100=0, r50=0, r20=0, r10=0, r5=0, r2=0 , r1=0 ,count=0;
cout<<"Enter The Amount in Rupees : \n\n" ;
cin>>amt ;
while(amt >= 2000)
{
r2000 = amt / 2000 ;
amt = amt % 2000;
cout<<"\nTotal Number Of 2000 Rupees Notes : "<< r2000 ;
break ;
}
while(amt >= 500)
{
r500 = amt / 500 ;
amt = amt % 500;
cout<<"\nTotal Number Of 500 Rupees Notes : "<< r500 ;
break ;
}
while(amt >= 100)
{
r100 = amt / 100 ;
amt = amt % 100;
cout<<"\nTotal Number Of 100 Rupees Notes : "<< r100 ;
break ;
}
while(amt >= 50)
{
r50 = amt / 50 ;
amt = amt % 50;
cout<<"\nTotal Number Of 50 Rupees Notes : "<< r50 ;
break ;
}
while(amt >= 20)
{
r20 = amt / 20 ;
amt = amt % 20;
cout<<"\nTotal Number Of 20 Rupees Notes : "<< r20 ;
break ;
}
while(amt >= 10)
{
r10 = amt / 10 ;
amt = amt % 10;
cout<<"\nTotal Number Of 10 Rupees Notes Or Coin : "<< r10 ;
break ;
}
while(amt >= 5)
{
r5 = amt / 5 ;
amt = amt % 5;
cout<<"\nTotal Number Of 5 Rupees Notes Or Coin : "<< r5 ;
break ;
}
while(amt >= 2)
{
r2 = amt / 2 ;
amt = amt % 2;
cout<<"\nTotal Number Of 2 Rupees Notes Or Coin : "<< r2 ;
break ;
}
while(amt >= 1)
{
r1 = amt / 1 ;
amt = amt % 1;
cout<<"\nTotal Number Of 1 Rupees Note Or Coin : "<< r1 ;
break ;
}
count = r2000 + r500 + r100 + r50 + r20 + r10 + r5 + r2 + r1;
cout<<"\n\nTotal Number Of Notes Require :"<< count<<endl ;
return 0;
}
Method 2 :- Denomination For USA Dollar
#include<bits/stdc++.h>
using namespace std;
int main()
{
/*Program By Ghanendra Yadav
Visit http://www.programmingwithbasics.com/
*/
int amt, r100=0, r50=0, r20=0, r10=0, r5=0, r2=0 , r1=0 ,count=0;
cout<<"Enter The Amount in Rupees : \n\n" ;
cin>>amt ;
while(amt >= 100)
{
r100 = amt / 100 ;
amt = amt % 100;
cout<<"\nTotal Number Of 100 Dollar Notes : "<< r100 ;
break ;
}
while(amt >= 50)
{
r50 = amt / 50 ;
amt = amt % 50;
cout<<"\nTotal Number Of 50 Dollar Notes : "<< r50 ;
break ;
}
while(amt >= 20)
{
r20 = amt / 20 ;
amt = amt % 20;
cout<<"\nTotal Number Of 20 Dollar Notes : "<< r20 ;
break ;
}
while(amt >= 10)
{
r10 = amt / 10 ;
amt = amt % 10;
cout<<"\nTotal Number Of 10 Dollar Or Coin : "<< r10 ;
break ;
}
while(amt >= 5)
{
r5 = amt / 5 ;
amt = amt % 5;
cout<<"\nTotal Number Of 5 Dollar Or Coin : "<< r5 ;
break ;
}
while(amt >= 2)
{
r2 = amt / 2 ;
amt = amt % 2;
cout<<"\nTotal Number Of 2 Dollar Or Coin : "<< r2 ;
break ;
}
while(amt >= 1)
{
r1 = amt / 1 ;
amt = amt % 1;
cout<<"\nTotal Number Of 1 Dollar Or Coin : "<< r1 ;
break ;
}
count = r100 + r50 + r20 + r10 + r5 + r2 + r1;
cout<<"\n\nTotal Number Of Dollar Require :"<< count<<endl ;
return 0;
}
See Also :- Java Program For Denomination of an Amount
Output:-
Generally Notes are used in banks are given below in descending Order .Ii is dependent to country wise their are some country Denomination
INDIA ( Rupees ) USA ( Dollar ) INDIA ( Rupees )
( Before 8 Nov. 2016 ) ( Present ) ( Present )
1000 100 2000
500 50 500
100 20 100
50 10 50
20 5 20
10 2 10
5 1 5
2 2
1 1
Logic :- The Logic Behind we have to divide a money by Above Money lets take a example Suppose money is 16108 then follow the Step We are taking a example of Indian Currency In present
Step 1:- Then First we divide 16108 by 2000 then we get 8 ,2000 rs notes then go to step 2
Step 2:- After divide 2000 we get a remainder 108 The we know that 108 is not divisible by 500 so go to next step
Step 3:- Now divide 108 by 100 then we get 1 ,100 rs note now remainder is 8 go to next step
Step 4:- 8 is divisible by 50 and 20 nor 10 so we escape now go to next step
Step 5:- Now divide 8 by 5 we get a 1 ,5 rs notes and remainder is 3 so go to next step
Step 6:- Now divide 3 by 2 we get 1 ,2 rs notes and remainder is 1
so follow the next step
Step 7:- This is a Last step divide 1 by 1 we get zero remainder now print the total no of denomination needed and along with total no of count require to fulfill a requirement
So for 16108 You Need to
No.
8 * 2000 = 16000
1 * 100 = 100
1 * 5 = 5
1 * 2 = 2
1 * 1 = 1
Total =12 Notes For minimum Transaction
See Also :- C Program For Denomination of an Amount
Solution :-
Method 1 :- Denomination For Indian Rupees
#include<bits/stdc++.h>
using namespace std;
int main()
{
/*Program By Ghanendra Yadav
Visit http://www.programmingwithbasics.com/
*/
int amt, r2000=0, r500=0, r100=0, r50=0, r20=0, r10=0, r5=0, r2=0 , r1=0 ,count=0;
cout<<"Enter The Amount in Rupees : \n\n" ;
cin>>amt ;
while(amt >= 2000)
{
r2000 = amt / 2000 ;
amt = amt % 2000;
cout<<"\nTotal Number Of 2000 Rupees Notes : "<< r2000 ;
break ;
}
while(amt >= 500)
{
r500 = amt / 500 ;
amt = amt % 500;
cout<<"\nTotal Number Of 500 Rupees Notes : "<< r500 ;
break ;
}
while(amt >= 100)
{
r100 = amt / 100 ;
amt = amt % 100;
cout<<"\nTotal Number Of 100 Rupees Notes : "<< r100 ;
break ;
}
while(amt >= 50)
{
r50 = amt / 50 ;
amt = amt % 50;
cout<<"\nTotal Number Of 50 Rupees Notes : "<< r50 ;
break ;
}
while(amt >= 20)
{
r20 = amt / 20 ;
amt = amt % 20;
cout<<"\nTotal Number Of 20 Rupees Notes : "<< r20 ;
break ;
}
while(amt >= 10)
{
r10 = amt / 10 ;
amt = amt % 10;
cout<<"\nTotal Number Of 10 Rupees Notes Or Coin : "<< r10 ;
break ;
}
while(amt >= 5)
{
r5 = amt / 5 ;
amt = amt % 5;
cout<<"\nTotal Number Of 5 Rupees Notes Or Coin : "<< r5 ;
break ;
}
while(amt >= 2)
{
r2 = amt / 2 ;
amt = amt % 2;
cout<<"\nTotal Number Of 2 Rupees Notes Or Coin : "<< r2 ;
break ;
}
while(amt >= 1)
{
r1 = amt / 1 ;
amt = amt % 1;
cout<<"\nTotal Number Of 1 Rupees Note Or Coin : "<< r1 ;
break ;
}
count = r2000 + r500 + r100 + r50 + r20 + r10 + r5 + r2 + r1;
cout<<"\n\nTotal Number Of Notes Require :"<< count<<endl ;
return 0;
}
Method 2 :- Denomination For USA Dollar
#include<bits/stdc++.h>
using namespace std;
int main()
{
/*Program By Ghanendra Yadav
Visit http://www.programmingwithbasics.com/
*/
int amt, r100=0, r50=0, r20=0, r10=0, r5=0, r2=0 , r1=0 ,count=0;
cout<<"Enter The Amount in Rupees : \n\n" ;
cin>>amt ;
while(amt >= 100)
{
r100 = amt / 100 ;
amt = amt % 100;
cout<<"\nTotal Number Of 100 Dollar Notes : "<< r100 ;
break ;
}
while(amt >= 50)
{
r50 = amt / 50 ;
amt = amt % 50;
cout<<"\nTotal Number Of 50 Dollar Notes : "<< r50 ;
break ;
}
while(amt >= 20)
{
r20 = amt / 20 ;
amt = amt % 20;
cout<<"\nTotal Number Of 20 Dollar Notes : "<< r20 ;
break ;
}
while(amt >= 10)
{
r10 = amt / 10 ;
amt = amt % 10;
cout<<"\nTotal Number Of 10 Dollar Or Coin : "<< r10 ;
break ;
}
while(amt >= 5)
{
r5 = amt / 5 ;
amt = amt % 5;
cout<<"\nTotal Number Of 5 Dollar Or Coin : "<< r5 ;
break ;
}
while(amt >= 2)
{
r2 = amt / 2 ;
amt = amt % 2;
cout<<"\nTotal Number Of 2 Dollar Or Coin : "<< r2 ;
break ;
}
while(amt >= 1)
{
r1 = amt / 1 ;
amt = amt % 1;
cout<<"\nTotal Number Of 1 Dollar Or Coin : "<< r1 ;
break ;
}
count = r100 + r50 + r20 + r10 + r5 + r2 + r1;
cout<<"\n\nTotal Number Of Dollar Require :"<< count<<endl ;
return 0;
}
See Also :- Java Program For Denomination of an Amount
0 Comments: