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

  • SEARCH
  • Home
  • 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 9174159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:42:33+00:00 2026-06-17T16:42:33+00:00

I’m supposed to design a BankAcct class with an abstract method computeIntt() . Save

  • 0

I’m supposed to design a BankAcct class with an abstract method computeIntt(). Save and Time are kinds of BankAcct. The problem is I can’t implement the displaying of the Interest and the New balance

Here’s my current codes:

public abstract class BankAcct 
{
    private int accountNumber;
    private String accountName;
    private double bal;

    public BankAcct(int act, String name, double m)
    {
        accountNumber = act;
        accountName = name;
        bal = m;
    }

    public double getBalance()
    {
        return bal;
    }

    public String getAccountName()
    {
        return accountName;
    }

    public int getAccountNumber()
    {
        return accountNumber;
    }

    public void deposit(double m)
    {
            bal+=m;
    }

    public void withdraw(double m)
    {
        bal-=m;
    }

    public abstract double computeInt();
}

public class Save extends BankAcct 
{
    public Save(int act, String name, double m)
    {
        super(act, name, m);
    }

    int act;
    String name="";
    double m;

    public double computeInt()
    {
        return m * 0.0025;
    }

}

public class Time extends BankAcct 
{
    public Time(int act, String name, double m)
    {
        super(act, name, m);
    }

    int act;
    String name="";
    double m;

    public double computeInt()
    {
        return m * 0.033;
    }

}

public class MainPr 
{
    public static void main(String[] args)
    {
        BankAcct sav = new Savings(1234, "ABC", 10000);
        BankAcct td = new TimeDeposit(9876, "DEF", 20000);

        // display the current balance
    
        System.out.println(sav.getAccountName() + " with account number " +
                    sav.getAccountNumber() + " has a balance of " +
                    sav.getBalance());
    
        System.out.println(td.getAccountName() + " with account number " +
            td.getAccountNumber() + " has a balance of " +
            td.getBalance());
    
        // deposit money
    
        sav.withdraw(5000.0);
    
        // display current value with its interest
    
        System.out.println("\n" + sav.getAccountName() + " with account number " +
            sav.getAccountNumber() + " earned an interest of " +
            sav.computeInt());
    
        System.out.println(sav.getAccountName() + " with account number " +
            sav.getAccountNumber() + " has a NEW BALANCE of " +
            sav.getBalance());
    
        td.deposit(2000.0);
    
        System.out.println("\n" + td.getAccountName() + " with account number " +
            td.getAccountNumber() + " earned an interest of " +
            td.computeInt());
    
        System.out.println(td.getAccountName() + " with account number " +
            td.getAccountNumber() + " has a NEW BALANCE of " +
            td.getBalance());
    }
}

MainPr that will instantiate two objects for the following data:
Save has account number of 1234; account name of ABC; balance of 10,000.
Time has account number of 9876; account name DEF; balance of 20,000.

This should be the output: CORRECT ONE

ABC with account number 1234 has a balance of 10000.0

DEF with account number 9876 has a balance of 20000.0

ABC with account number 1234 earned interest 25.0

ABC with account number 1234 has a NEW balance of 5025.0

DEF with account number 9876 earned interest 660.0

DEF with account number 9876 has a NEW balance of 22660.0

but my program produces the incorrect output:

ABC with account number 1234 has a balance of 10000.0

DEF with account number 9876 has a balance of 20000.0

ABC with account number 1234 earned interest 0.0

ABC with account number 1234 has a NEW balance of 5000.0

DEF with account number 9876 earned interest 0.0

DEF with account number 9876 has a NEW balance of 22000.0

In this case, in Save the interest rate is 0.25% while the interest in time is 3.3% The balance depends whether it is deposit or withdraw.

Kindly help me. thanks

  • 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-06-17T16:42:34+00:00Added an answer on June 17, 2026 at 4:42 pm

    Your instance variables m are always 0 (never initialized) in your subclasses, but they look like they are set to the bal in your BankAcct class. Wouldn’t this be appropriate for your computerInterest method in TimeDeposit:

    public double computeInterest() {
        return getBalance() * 0.033;
    }
    

    A similar fix should be provided in the other subclass or at least initialize your m variables. On a related note, your subclasses don’t need to define act or name since your superclass BankAcct has it defined and stored already.

    Also, your computerInterest isn’t modifying your balance, which your program seems to expect. If that’s the case, this might be more appropriate:

    public double computeInterest() {
        double interest = getBalance() * 0.033;
        deposit(interest);
        return interest;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I have been unable to fix a problem with Java Unicode and encoding. The
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Let's say I'm outputting a post title and in our database, it's Hello Y’all

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.