Write a program with subclass InterestAccount and CDAccount. The driver program (Account.java) must perform following transactions:

1) Print the name of your bank and yours at the top.
2) Creat an Intrest Account for "Benjamin Franklin" with PIN of 1234 and a starting balance of $100.
3) Creat a CD Account for "William Shakespeare" with PIN of 4321 and a statring balance of &1000.
4) Do three monthly updates, printing out the amount in each account.
5) Deposit $1000 in the Amazon's accounts.
6) Withdraw $500 from Ebay's accounts.
7) Do at least 10 times or more monthly updates, printing out the amounts in each account.

Program should be stores in Account.java, Acount types IntrestAccount.java and CDAccount.java.

Account.java

    //Demonstrates the BankAccount and derived classes

import java.text.*;         // to use Decimal Format
import java.util.*;
import java.io.*;
import AccountKinds.*;

public class Account extends Object
{
    public static void main(String[] args)
    {
        double put_in = 500;
        double take_out = 1000;

        DecimalFormat myFormat;
        String money;
        String money_in;
        String money_out;
        boolean completed;

            // to get 2 decimals every time
        myFormat = new DecimalFormat("#.00");

            //to test the Checking Account class
        CheckingAccount anAccount;
        anAccount = new CheckingAccount ("Benjamin Franklin", 1234);
        System.out.println ("Account Number "
                                                + anAccount.getAccountNumber() + "-10"+
                                                " belonging to " + anAccount.getOwner());
        money  = myFormat.format(anAccount.getBalance());
        System.out.println ("Initial balance = $" + money);
        anAccount.deposit (put_in);
        money_in = myFormat.format(put_in);
        money  = myFormat.format(anAccount.getBalance());
        System.out.println ("After deposit of $" + money_in
                                                + ",  balance = $" + money);
        completed = anAccount.withdraw(take_out);
        money_out = myFormat.format(take_out);
        money  = myFormat.format(anAccount.getBalance());
        if (completed)
        {
            System.out.println ("After withdrawal of $" + money_out
                                                    + ",  balance = $" + money);
        }
        else
        {
            System.out.println ("Insuffient funds to withdraw $"
                                                    + money_out + ",  balance = $" + money);
        }
        System.out.println();

            //to test the savings account class
        SavingsAccount yourAccount =
        new SavingsAccount ("William Shakespeare", 4321);
        System.out.println ("Account Number "
                                                + yourAccount.getAccountNumber() +"-0"+
                                                " belonging to " + yourAccount.getOwner());
        money  = myFormat.format(yourAccount.getBalance());
        System.out.println ("Initial balance = $" + money);
        yourAccount.deposit (put_in);
        money_in = myFormat.format(put_in);
        money  = myFormat.format(yourAccount.getBalance());
        System.out.println ("After deposit of $" + money_in
                                                + ",  balance = $" + money);
        completed = yourAccount.withdraw(take_out);
        money_out = myFormat.format(take_out);
        money  = myFormat.format(yourAccount.getBalance());
        if (completed)
        {
            System.out.println ("After withdrawal of $" + money_out
                                                    + ",  balance = $" + money);
        }
        else
        {
            System.out.println ("Insuffient funds to withdraw $"
                                                    + money_out + ",  balance = $" + money);
        }
        yourAccount.postInterest();
        money  = myFormat.format(yourAccount.getBalance());
        System.out.println ("After monthly interest has been posted,"
                                                + "balance = $" + money);
        System.out.println();


            // to test the copy constructor of the savings account class
        SavingsAccount secondAccount =
        new SavingsAccount (yourAccount,5);
        System.out.println ("Account Number "
                                                + secondAccount.getAccountNumber()+"-1"+
                                                " belonging to " + secondAccount.getOwner());
        money  = myFormat.format(secondAccount.getBalance());
        System.out.println ("Initial balance = $" + money);
        secondAccount.deposit (put_in);
        money_in = myFormat.format(put_in);
        money  = myFormat.format(secondAccount.getBalance());
        System.out.println ("After deposit of $" + money_in
                                                + ", balance = $" + money);
        secondAccount.withdraw(take_out);
        money_out = myFormat.format(take_out);
        money  = myFormat.format(secondAccount.getBalance());
        if (completed)
        {
            System.out.println ("After withdrawal of $" + money_out
                                                    + ",  balance = $" + money);
        }
        else
        {
            System.out.println ("Insuffient funds to withdraw $"
                                                    + money_out + ",  balance = $" + money);
        }
        System.out.println();

            //to test to make sure new accounts are numbered correctly
        CheckingAccount yourCheckingAccount =
        new CheckingAccount ("Issac Newton", 5000);
        System.out.println ("Account Number "
                                                + yourCheckingAccount.getAccountNumber()
                                                + " belonging to "
                                                + yourCheckingAccount.getOwner());

    }
}

InterestAccount.java

    //Defines any type of bank account
package AccountKinds;

public abstract class CheckigAccount
{
        // class variable so that each account has a unique number
    protected static int numberOfAccounts = 100001;

        // current balance in the account
    private double balance;
        // name on the account
    private String owner;
        // number bank uses to identify account
    private String accountNumber;

        //default constructor
    public CheckingAccount()
    {
        balance = 0;
        accountNumber = numberOfAccounts + "";
        numberOfAccounts++;
    }

        //standard constructor
    public CheckingAccount(String name, double amount)
    {
        owner = name;
        balance = amount;
        accountNumber = numberOfAccounts + "";
        numberOfAccounts++;
    }

        //copy constructor
    public CheckingAccount(CheckingAccount oldAccount, double amount)
    {
        owner = oldAccount.owner;
        balance = amount;
        accountNumber = oldAccount.accountNumber;
    }

        //allows you to add money to the account
    public void deposit(double amount)
    {
        balance = balance + amount;
    }

        //allows you to remove money from the account if
        //enough money is available
        //returns true if the transaction was completed
        //returns false if the there was not enough money
    public boolean withdraw(double amount)
    {
        boolean completed = true;

        if (amount <= balance)
        {
            balance = balance - amount;
        }
        else
        {
            completed = false;
        }
        return completed;
    }

        //accessor method to balance
    public double getBalance()
    {
        return balance;
    }

        //accessor method to owner
    public String getOwner()
    {
        return owner;
    }

        //accessor method to account number
    public String getAccountNumber()
    {
        return accountNumber;
    }

        //mutator method to change the balance
    public void setBalance(double newBalance)
    {
        balance = newBalance;
    }

        //mutator method to change the account number
    public void setAccountNumber(String newAccountNumber)
    {
        accountNumber = newAccountNumber;
    }
}

CDAccount.java

package AccountKinds;


public class SavingsAccount extends CheckingAccount
{
    public SavingsAccount(String string, double rate)
    {
        interestRate = rate;
    }
    public SavingsAccount(SavingsAccount yourAccount, int rate) {

    }
    public void addInterest()
    {
        double interest = getBalance() * interestRate / 100;
        deposit(interest);
    }
    private double interestRate;



    public void deposit(double amount) {}
    public boolean withdraw(double amount) {
        return false;}
    public void deductFees() {}
    private int transactionCount;



    public void postInterest() {
        double balance = getBalance();
        balance += (balance * interestRate);
        deposit(balance);

    }
}

I am getting errors:

Account.java:25: cannot find symbol
symbol  : class CheckingAccount
location: class Banking
        CheckingAccount anAccount;
        ^
Account.java:26: cannot find symbol
symbol  : class CheckingAccount
location: class Banking
        anAccount = new CheckingAccount ("Benjamin Franklin", 1000);
                        ^
./AccountKinds/SavingsAccount.java:4: cannot find symbol
symbol: class CheckingAccount
public class SavingsAccount extends CheckingAccount
                                    ^
Account.java:56: cannot find symbol
symbol  : method getAccountNumber()
location: class AccountKinds.SavingsAccount
                                        + yourAccount.getAccountNumber() +"-0"+
                                                     ^
Account.java:57: cannot find symbol
symbol  : method getOwner()
location: class AccountKinds.SavingsAccount
                                        " belonging to " + yourAccount.getOwner());
                                                                      ^
Account.java:58: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        money  = myFormat.format(yourAccount.getBalance());
                                            ^
Account.java:62: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        money  = myFormat.format(yourAccount.getBalance());
                                            ^
Account.java:67: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        money  = myFormat.format(yourAccount.getBalance());
                                            ^
Account.java:79: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        money  = myFormat.format(yourAccount.getBalance());
                                            ^
Account.java:89: cannot find symbol
symbol  : method getAccountNumber()
location: class AccountKinds.SavingsAccount
                                        + secondAccount.getAccountNumber()+"-1"+
                                                       ^
Account.java:90: cannot find symbol
symbol  : method getOwner()
location: class AccountKinds.SavingsAccount
                                        " belonging to " + secondAccount.getOwner());
                                                                        ^
Account.java:91: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        money  = myFormat.format(secondAccount.getBalance());
                                              ^
Account.java:95: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        money  = myFormat.format(secondAccount.getBalance());
                                              ^
Account.java:100: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        money  = myFormat.format(secondAccount.getBalance());
                                              ^
Account.java:114: cannot find symbol
symbol  : class CheckingAccount
location: class Banking
        CheckingAccount yourCheckingAccount =
        ^
Account.java:115: cannot find symbol
symbol  : class CheckingAccount
location: class Banking
        new CheckingAccount ("Issac Newton", 5000);
            ^
./AccountKinds/SavingsAccount.java:15: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        double interest = getBalance() * interestRate / 100;
                          ^
./AccountKinds/SavingsAccount.java:31: cannot find symbol
symbol  : method getBalance()
location: class AccountKinds.SavingsAccount
        double balance = getBalance();
                         ^
18 errors

Thanks'

the class name in your code is
'CheckigAccount' (without n)
that might be your problem.

Yes. That's the problem. Thanks' stultuske.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.