Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: help pleasee

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help pleasee

    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;
    }
    }
    Last edited by KevinWorkman; March 22nd, 2011 at 08:04 AM. Reason: added highlight tags


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,256
    My Mood
    Hungover
    Thanks
    142
    Thanked 618 Times in 529 Posts

    Default Re: help pleasee

    When posting code, make sure you use the code or highlight tags. I added them for you this time, but please be more mindful in the future.

    Anyway, this isn't a homework service. What have you tried? How would you do this by hand, without a computer?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,511
    My Mood
    Grumpy
    Thanks
    0
    Thanked 165 Times in 156 Posts

    Default Re: help pleasee

    balance = balance;
    Totally pointless, get rid of it.
    maxBalance = maxBalance;
    Ditto.

    I'm confused. You managed to write the deposit and maxBalance code but cannot write the withdrawal and minBalance code. They are almost identical.

Tags for this Thread