Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Banks and other financial service companies offer many types of accounts for cli

ID: 3651395 • Letter: B

Question

Banks and other financial service companies offer many types of accounts for client's to invest their fund-- every one of them has a notion of their current value, but the details of calculating such value depends upon the exact nature of the account. Write an abstract class, Account, with the following: - an integer static variable, nextId initialized to 10001 - an integer instance variable, id - a string instance variable name - a constructor that accepts a single string parameter used to initialize the name instance variable. The constructor also assigns to id the value of nextId which is then incremented. - two accessor methods, getId and getName which return the values of the corresponding instance variables - an abstract method named getValue that accepts no parameters and returns and object of type Cash.

Explanation / Answer

abstract class Account
{
    static int nextId=10001;
    int id;
    String name;
    Account(String s)
    {
        name=s;
        id=nextId;
        nextId++;
    }
    public int getId()
    {
        return id;
    }
    public String getName()
    {
        return name;
    }
    public abstract Cash getValue()
    {
        return cash;
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote