A BankAccount has to allow up to a maximum of three holders (person) **Use vecto
ID: 3909102 • Letter: A
Question
A BankAccount has to allow up to a maximum of three holders (person) **Use vectors for holders**
////////////////////////////////////////
public class BankAccount {
private Person person;
private double balance;
private double interest;
private Date openingdate;
private Date interestpaiddate;
public BankAccount(double bal, double intr, Person p, Date o)
{
balance = bal;
interest = intr;
person = p;
openingdate = o;
interestpaiddate = new Date();
}
//getters
public double getBalance() {
return balance;
}
public double getInterest() {
return interest;
}
public String getOpeningDate() {
return openingdate.toString();
}
public String getInterestPaidDate() {
return interestpaiddate.toString();
}
public String getLastName()
{
return person.getLName();
}
public int getSSN()
{
return person.getSSN();
}
//setters
public void deposit(double amount)
{
balance = balance + amount;
}
public void withdraw(double amount)
{
balance = balance - amount;
}
public void addInterest(String d)
{
balance = balance + balance * interest;
interestpaiddate = new Date(d);
}
public void setFName(String n) {
person.setFName(n);
}
public void setLName(String n) {
person.setLName(n);
}
public void setAddress(String a){
person.setAddress(a);
}
public void setSSN(int n) {
person.setSSN(n);
}
public void setDOB(String s){
person.setDate(s);
}
public void setDOB(int m, int d, int y){
String date = m+"/"+d+"/"+y;
person.setDate(date);
}
public String toString() {
String st = "Bank Account Information " +
"Account Holder: " +
person.toString() + " " +
"Balance Amount: " + getBalance() + " " +
"Opening Date: " + getOpeningDate() + " " +
"Last Interest Added Date: " + getInterestPaidDate();
return st;
}
}
Explanation / Answer
Please find the code below:
package classes1;
import java.util.Vector;
public class BankAccount {
private Vector<Person> holder;
private double balance;
private Person person;
private double interest;
private Date openingdate;
private Date interestpaiddate;
public BankAccount(double bal, double intr,Vector<Person> holders, Date o)
{
balance = bal;
interest = intr;
holder = holders;
openingdate = o;
interestpaiddate = new Date();
}
//getters
public double getBalance() {
return balance;
}
public double getInterest() {
return interest;
}
public String getOpeningDate() {
return openingdate.toString();
}
public String getInterestPaidDate() {
return interestpaiddate.toString();
}
public Vector<Person> getHolder(){
return holder;
}
public void setHolder(Vector<Person> inHolder){
holder = inHolder;
}
//setters
public void deposit(double amount)
{
balance = balance + amount;
}
public void withdraw(double amount)
{
balance = balance - amount;
}
public void addInterest(String d)
{
balance = balance + balance * interest;
interestpaiddate = new Date(d);
}
public String toString() {
String st = "Bank Account Information " +
"Account Holders: " +
holder.toString() + " " +
"Balance Amount: " + getBalance() + " " +
"Opening Date: " + getOpeningDate() + " " +
"Last Interest Added Date: " + getInterestPaidDate();
return st;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.