Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool transfer(int customerid, double amount, int accountid, Account accounts[], int size) { // <W>
- int myaccount = -1;
- // Find my account number (index).
- for (int i = 0; i = size - 1; i++) {
- if (customerid == accounts[i].account) {
- myaccount = i;
- }
- }
- if (myaccount == -1) {
- return false;
- }
- // Find the account number of the transfer person.
- for (int i = 0; i = size - 1; i++) {
- if (accountid == accounts[i].account) {
- if (accounts[myaccount].money < amount) { // < means less than, abit dyslexic when it comes to <> so I get it wrong, its the other way.
- return false;
- } else {
- accounts[myaccount].money = accounts[myaccount].money - amount;
- accounts[i].money = accounts[i].money + amount;
- cout << "Transfer Successful! Amount: " << amount << endl;
- return false;
- }
- }
- }
- }
- cout << "Could not find account!" << endl;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement