Brandan

Untitled

Feb 19th, 2014
187
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     bool transfer(int customerid, double amount, int accountid, Account accounts[], int size) { // <W>
  2.             int myaccount = -1;
  3.             // Find my account number (index).
  4.             for (int i = 0; i = size - 1; i++) {
  5.                 if (customerid == accounts[i].account) {
  6.                     myaccount = i;
  7.                 }
  8.             }
  9.  
  10.             if (myaccount == -1) {
  11.                 return false;
  12.             }
  13.  
  14.             // Find the account number of the transfer person.
  15.             for (int i = 0; i = size - 1; i++) {
  16.                 if (accountid == accounts[i].account) {
  17.                     if (accounts[myaccount].money < amount) { // < means less than, abit dyslexic when it comes to <> so I get it wrong, its the other way.
  18.                         return false;
  19.                     } else {
  20.                         accounts[myaccount].money = accounts[myaccount].money - amount;
  21.                         accounts[i].money = accounts[i].money + amount;
  22.                         cout << "Transfer Successful! Amount: " << amount << endl;
  23.                         return false;
  24.                     }
  25.                 }
  26.             }
  27.         }
  28.         cout << "Could not find account!" << endl;
  29.         return true;
  30.     }
RAW Paste Data