Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7072649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:50:04+00:00 2026-05-28T05:50:04+00:00

Ok,so I am getting a lot of trouble, I am still learning Java and

  • 0

Ok,so I am getting a lot of trouble, I am still learning Java and my book has set me a task that I find common over the net, the part that I am stuck on is…

I must create a bank account program, an account holder is given a savings account (which has an interest rate and no overdraft facility), and a checking account (which has an overfraft facility of £100 and no interest).

I am not implementing the overdraft yet and am only half way to getting the withdraw and deposit function ready but my question is with the interest, I have defined in my superclass the savings account balance and the checking account balance so when working out my interest in the savings account class I cannot reference savebalance as I have made it private. I am trying to use the set.name method but i am clearly doing it wrong….

A big smile and a thank you for any one who can help or give advice!

Superclass is as follows:

public class BankDetails
    {
        private String customer;
        private String accountno;
        private double savebalance;
        private double checkbalance;


//Constructor Methods

 public BankDetails(String customerIn, String accountnoIn, double savebalanceIn, double checkbalanceIn)
        {
            customer = customerIn;
            accountno = accountnoIn;
            savebalance = savebalanceIn;
            checkbalance = checkbalanceIn;
        }

      // Get  name
      public String getcustomername()
        {
            return (customer);
        }

      // Get account number
      public String getaccountnumber()
        {
            return (accountno);
        }

       public double getcheckbalanceamount()
        {
            return (checkbalance);
        }

       public double getsavebalanceamount()
        {
            return (savebalance);
        }


public void savewithdraw(double savewithdrawAmountIn)

  {
        savebalance = savebalance - savewithdrawAmountIn;

  }

public void checkwithdraw(double checkwithdrawAmountIn)

  {
        checkbalance = checkbalance - checkwithdrawAmountIn;

  }


 public void savedeposit(double savedepositAmountIn)

  {
        savebalance = savebalance - savedepositAmountIn;

  }

public void checkdeposit(double checkdepositAmountIn)

  {
        checkbalance = checkbalance - checkdepositAmountIn;

  }




    } // End Class BankDetails

Sub Class is as follows:

    import java.util.*; 

public class Savings extends BankDetails
  {

      private String saveaccount;
      private double interest;


      public Savings(String customerIn, String accountnoIn, float interestIn, 
      String saveaccountIn, double savebalanceIn)
        {


            super (customerIn, accountnoIn, savebalanceIn, interestIn);


            saveaccount = saveaccountIn;
            interest = interestIn;

        }


      public String getsaveaccountno()
       {
           return (saveaccount);
       }

      public double getinterestamount()
       {
           return (interest);
       }


      public void interestamount(String[] args)

       {
           BankDetails.getsavebalanceamount(savebalance);
           interest = (savebalance / 100) * 1.75;


       }


       }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:50:04+00:00Added an answer on May 28, 2026 at 5:50 am

    Use the superclass’s getSaveBalance() method to access the balance (which is suspiciously-named, since you have a savings account class, but keep the balance elsewhere).

    (Currently it’s getsavebalanceamount(), I assume a renaming to keep with Java conventions.)


    I’d recommend using consistent CamelCase when naming your getters and setters, e.g., getInterestAmount(), getSaveAccountNo(), etc.

    I recommend against commenting simple getters/setters, but if you do, use Javadoc conventions, e.g.:

    /** Returns current savings account balance. */
    public double getSaveBalance() { ... etc ... }
    

    I also recommend avoid unnecessary parentheses, as currently in your getters, e.g.:

    public double getSaveBalance() {
        return saveBalance; // No parens required.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read a lot a blogs and forums but I'm still having trouble getting
Having a lot of trouble getting texture maps to work in openGL ES (iphone).
I'm having a lot of trouble getting my priority queue to recognize which parameter
I am getting ready to write lot of small experimental java programs as I
I'm having a lot of trouble getting my compiled assembly file working on SPIM.
I am having a lot of trouble getting m core data objects to be
I'm working with Core Data and having a lot of trouble's getting data into
I'm having a lot of trouble getting a simple true/false to evaluate properly in
I have been having a lot of trouble getting cocotron to create a simple
I am having a lot of trouble right now getting my navigaton bar to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.