// Author: Kevin Ching

// Class: CSC 170T

// Date: January 30, 1999

// Instructor: Erik Steinmetz

// Assignment: 3B

//

// Bank_Account.java

// Simulates bank account activities.

class Bank_Account {

private double dbBalance;

private float flInterest_rate;

private String stName;

// Initialize balance when opening account.

public Bank_Account () {

stName = "Invalid Name";

dbBalance = 0;

flInterest_rate = 0;

}

public Bank_Account (String customer) {

stName = customer;

dbBalance = 0;

flInterest_rate = 0;

}

public Bank_Account (double deposit) {

stName = "Invalid Name";

dbBalance = deposit;

flInterest_rate = 0;

}

public Bank_Account (float yield) {

stName = "Invalid Name";

dbBalance = 0;

flInterest_rate = yield;

}

public Bank_Account (String customer, double deposit, float yield) {

stName = customer;

dbBalance = deposit;

flInterest_rate = yield;

}

public Bank_Account (String customer, double deposit) {

stName = customer;

dbBalance = deposit;

flInterest_rate = 0;

}

public Bank_Account (String customer, float yield) {

stName = customer;

dbBalance = 0;

flInterest_rate = yield;

}

public Bank_Account (double deposit, float yield) {

stName = "Invalid Name";

dbBalance = deposit;

flInterest_rate = yield;

}

// Make a deposit.

public void credit (double deposit) {

dbBalance = dbBalance + deposit;

}

// Make a withdrawal.

public void debit (double withdrawal) {

if (withdrawal > 0)

dbBalance = dbBalance - withdrawal;

else

System.out.println

("You have entered an illegal amount. Try again.") ;

}

// Make a balance inquiry.

public double inquiry () {

int nCents = (int)(dbBalance * 100 + 0.5) ;

return nCents / 100.0 ;

}

// Read name.

public String get_name () {

return stName;

}

// Read interest.

public double get_interest () {

return flInterest_rate;

}

// Update account with interest earned at end of month.

public void monthlyUpdate () {

dbBalance = dbBalance * (1.0 + (flInterest_rate/100)) ;

}

} // class Bank_Account