Advertisement
fueanta

Cash Notes distributing

Sep 6th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. // Cpp program to distribute cash notes
  2. // created on May, 2016
  3. // Author: fueanta
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main() {
  9.     int notes[7]={100,50,20,10,5,2,1};
  10.     int quantities[7]={0,0,0,0,0,0,0};
  11.     int cash;
  12.     cout << "Amount of cash?\n" << endl;
  13.     cout << "Tk: ";
  14.     cin >> cash;
  15.     for (int i=0,j=0;cash>=0;i++) {
  16.         j=cash/notes[i];
  17.         if (j>0) {
  18.             quantities[i]=j;
  19.         }
  20.         cash=cash-(notes[i]*j);
  21.         if (cash<1)
  22.             break;
  23.     }
  24.     cout << "\nNotes to be given :\n******************* " << endl;
  25.     for (int i=0;i<7;i++) {
  26.         cout << quantities[i] << " note(s) of Tk: " << notes[i] << ".00" << endl;
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement