hi please help with this bankaccount assignment i have.
i want to find the minimum and maximum balance the account has based on deposits and withdrawals only. Then following that it should also give sum of deposits and sum of withdrawals made so far.
ive finsihed my code for method deposit, withdraw and maximumbalance. but im stuck on minimum balance and sum of deposits and withdrawals.
i have the get methodes i.e return the min max and sums methods when callled upon it.
heres my code what am i doing wrong here?
public class bankaccount { /** i. * In this Bankaccount it includes; balance, accountName. */ private int balance; private String accountName; private int deposit ; private int withdraw; private int sumOfDeposits; private int sumOfWithdrawals; private int maxBalance; private int minBalance; /** * constructors bankaccount with inital balance which ( not negative) * identifying accountname string. */ public BankAccount( String accountname, int newBalance ) { balance = newBalance ; accountName = accountname; } /** * method to getBalance i.e the current balance of the bankaccount object. */ public int getBalance () { return balance; } /** * method to get the uniques accountname (String) of an account user. */ public String getAccountName () { return accountName; } /** *Deposit amount which gets added to balance, amount would be not negative includes maxbalance. */ public void deposit(int amount) { if ( amount >= 0 ) balance = balance + amount; else balance = balance; if (balance >= maxBalance) maxBalance = balance; else maxBalance = maxBalance; } /** * Withdraw amount by decreasing balance. * @param amount non-negative */ public void withdraw(int amount) { } /** * method which gets the sum of deposits made in an account. */ public int getDeposits() { return sumOfDeposits; } /** *method which returns sum of withdrawals made in an account. */ public int getWithdrawals() { return sumOfWithdrawals; } /** * method returns the minimumBalance in the accounts trans history. */ public int getminBalance() { return minBalance; } /** *method returns the maxbalance in the accounts history. */ public int getmaxBalance() { return maxBalance; } }