Hi guys, i have been able to get this transfer function to work but only with one account. i'm not too sure how to get it working for the other account also. Any help would be greatly appreciated.

static String doTransfer(String amount){ 
    // Withdraw cash -- called from ATMWithdrawl
    String newBalance = "";
    String newBalance1 = "";
    // Turn Strings to doubles for arithmatic
    double transferAmount=                 
        (new Double(amount)).doubleValue();
    double currentBalance= 
        (new Double(account_inf[0][4])).doubleValue(); 
    double currentBalance1= 
        (new Double(account_inf[1][4])).doubleValue(); 
    // Get the new balance as a string & update the account_inf array    
    if (transferAmount <= currentBalance) {
    newBalance = Double.toString
                    (currentBalance - transferAmount);
      account_inf[0][4] = newBalance;
      newBalance1 = Double.toString
                    (currentBalance + transferAmount);
      account_inf[1][4] = newBalance1;
      else if (transferAmount <= currentBalance1) {
    newBalance1 = Double.toString
                    (currentBalance1 - transferAmount);
      account_inf[1][4] = newBalance;
    newBalance = Double.toString
                    (currentBalance1 + transferAmount);
      account_inf[0][4] = newBalance1;
    return newBalance;


I'm putting the problem down to not being able to use more than 1 return statement?

6 Years
Discussion Span
Last Post by JeffGrigg

Looks to me like "account_inf" holds the information of all of your accounts, so in order to make it work you should add two more parameters to that method to tell it which accounts to access from the array.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.