Tuesday, February 28, 2012

Challenge 041



public class BankAccount
{
    public double balance;
   
    public BankAccount() {
       
        balance = 0;
       
    }
    public BankAccount(double start)
    {
        balance = start;
    }
    public void Deposit(double amount)
    {
        balance += amount;
        System.out.println("Current balance: $" + balance);
    }
    public void Withdrawl(double amount)
    {
        if(balance >= balance)
        {
            balance -= amount;
            System.out.println("Current balance: $" + balance);
        }
            else
            {
                System.out.println("Insufficient Funds");
            }
    }
    public double getBalance()
    {
        return balance;
    }
}





public class SavingsAccount extends BankAccount
{
    public double interestRate;
    public SavingsAccount(double rate, double start)
    {
        super(start);
        interestRate = rate;
    }
    public double compInterestRate()
    {
        return balance = (balance * interestRate);
    }
}




public class CheckingAccount extends BankAccount
{
    public double minBalance;
    public double fee;
    public CheckingAccount()
    {
    }
   
    public CheckingAccount(double start)
    {
        super(start);
        minBalance = 50.0;
        fee = 2.0;
    }
    public double makeWithdraw(double amount)
    {
        balance -= amount;
        if (balance < minBalance)
        {
            System.out.print("$2.0 fee will be charged due to overdrawing" + (balance + fee));
        }
            else
            {
                System.out.print("Current balance: $" + balance);
            }
        }      
    }