//The following is an example of inheritance or "extending a class". It  shows how a Bank Class
// can be extended to be a bank class that generates monthly interest
// there is no need to write whole class over - just new methods and constructors
// if needed



public class Bank
{
       double balance;
       
        public Account( double amount )
              {
		balance = amount;
	}

        public Account()  // default constructor
	{
		balance = 0.0;
	}

        public void deposit( double amount )
	{
		balance += amount;
	}

        public double withdraw( double amount )  // return amount withdrawn
	{
                         if (balance >= amount)
		{
			balance -= amount;
                                                return amount;
		}
		else
                                    return 0.0;   
	}

        public double getBalance()
	{
                return balance;
	}
}  

**************************************************************

class Bank2 extends Bank
{
        private static double default_interest = .045;

        private double interest_rate;

        public Bank2( double amount, double interest)
	{
		super(amount);
		interest_rate = interest;
	}

        public Bank2( double amount )
	{
		super(amount);
		interest_rate = default_interest;
	}

        public Bank2()           
	{
		super(0);
		interest_rate = default_interest;
	}
	
        public void add_monthly_interest()
	{
		deposit( balance + ((balance * interest_rate) / 12);
	}
             }