IPA41
IPA41
accountNumber - int
accountHolderName - String
balance - double
withdraw method:
------------------------------------------
This method will take two input parameters - array of BankAccount objects and the
account number (int) from which withdrawal
should be done.
The method will check if the account number is present in the array of BankAccount
objects.
If present, the method will then check if the balance is sufficient to withdraw the
requested amount (double). If yes, it will
deduct the amount from the account balance and return the updated balance.
If the account number is not present or the balance is not sufficient, the method
should return -1.
deposit method:
--------------------------------------------
This method will take two input parameters - array of BankAccount objects and the
account number (int) in which deposit should
be done.
The method will check if the account number is present in the array of BankAccount
objects.
If present, it will add the deposit amount (double) to the account balance and
return the updated balance.
If the account number is not present, the method should return -1.
These above mentioned static methods should be called from the main method.
For withdraw method - The main method should print the updated balance if the
returned value is greater than or equal to 0, or
it should print "Sorry - Insufficient balance" if the returned value is -1, or it
should print "Sorry - Account not found" if
the returned value is -2.
For deposit method - The main method should print the updated balance if the
returned value is greater than or equal to 0, or
it should print "Sorry - Account not found" if the returned value is -1.
Input
------------------------
1001
Alice
5000.0
1002
Bob
10000.0
1003
Charlie
15000.0
1002
5000.0
1001
10000.0
Output
---------------------------
5000.0
15000.0