/*Design a class BankAccount that has the following properties:
* Account Number (should be static and increased every time an account is created.
* An array of holders max 5 and a holder is a Person object
* A int to rember how many holders
* Balance (float)
* Date opened
* interest rate
* Constructors
* addHolder will add one more Person as a holder, if you reach 5 don't add.
* Setters getters
* method payInterest that add interest to the accoun t
* method Deposit(float )
* method Withdraw(float)
* toString()
*
*/
public class BankAccount {
public String toString() {
String st = "";
//keep adding to it whatever you need
return st;
}
}Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
// Person.java
public class Person {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "Name=" + name + ", Age=" +
age;
}
}
________________________
// BankAccount.java
import java.util.Date;
public class BankAccount {
private static int accountNumber;
private Person holders[] = new Person[5];;
private int cntHolders=0;
private float balance;
private Date dateOpened;
private float interestRate;
public BankAccount(float balance, float
interestRate) {
this.cntHolders = 0;
this.balance = balance;
this.dateOpened = new Date();
this.interestRate =
interestRate;
accountNumber = 1111;
}
public void addHolder(Person p) {
if(cntHolders<holders.length)
{
this.holders[cntHolders] = p;
cntHolders++;
}
}
public static int getAccountNumber() {
return accountNumber;
}
public Person[] getHolders() {
return holders;
}
public int getCntHolders() {
return cntHolders;
}
public float getBalance() {
return balance;
}
public Date getDateOpened() {
return dateOpened;
}
public float getInterestRate() {
return interestRate;
}
public void setInterestRate(float interestRate)
{
this.interestRate =
interestRate;
}
public void payInterest() {
this.balance = balance + balance *
(interestRate / 100);
}
public void deposit(float amt) {
this.balance += amt;
}
public void withdraw(float amt) {
if (balance - amt >= 0)
this.balance -=
amt;
}
public String toString() {
String st = "";
//keep adding to it whatever you need
for(int i=0;i<cntHolders;i++)
{
st+="Name :"+holders[i].getName()+" Age
:"+holders[i].getAge()+"\n";
st+="Account Number :"+accountNumber+"\n";
accountNumber++;
st+="Date Opened :"+dateOpened+"\n";
st+="Balance :$"+balance+"\n";
}
return st;
}
}
______________________________
// Test.java
public class Test {
public static void main(String[] args) {
BankAccount ba=new BankAccount(50000,5);
ba.addHolder(new Person("Kane Williams",24));
ba.addHolder(new Person("James",25));
System.out.println(ba);
}
}
________________________________
Output:
Name :Kane Williams Age :24
Account Number :1111
Date Opened :Sun May 26 01:56:15 IST 2019
Balance :$50000.0
Name :James Age :25
Account Number :1112
Date Opened :Sun May 26 01:56:15 IST 2019
Balance :$50000.0
______________________________Thank You
/*Design a class BankAccount that has the following properties: * Account Number (should be static and increased every...
C++ Please create the class named BankAccount with the following properties below: // The BankAccount class sets up a clients account (name & ID), keeps track of a user's available balance. // It also keeps track of how many transactions (deposits and/or withdrawals) are made. public class BankAccount { Private String name private String id; private double balance; private int numTransactions; // Please define method definitions for Accessors and Mutator functions below Private member variables string getName(); // No set...
c++ please Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member func- tions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 compo- nents of...
2. Write a class called ATMTransaction. This class has a
variable balance and
account number.
It has three methods, checkBalance, deposit and withdraw along with
constructors
getters and setters and a toString. Write a program that
creates an object of this class. I should be able to deposit and
withdraw from
my account number based on my balance , but i shouldnt be able to
change my
account number. Look for loopholes in your program, test it
correctly, your
balance...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...
The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement these methods: void deposit(double amount) and void withdraw(double amount). For both these methods,...
Create Student class•Change header so that Student extends Person•A Student has-an additional instance variable, major of type String.•Add the instance variable, its getters and setters. •Add a toString method to the Student class. It should reuse the toString method of Person. •Add two constructors: –No args–Constructor that receives the student’s name, birth year and Major as parameters•Create a class TestInheritance3–Create 2 Student objects–Create an Instructor object–Print the information about the two students and the instructor using the getters of Person,...
Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member functions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also, declare an array of 10 components of type bankAccount to process up...
14 b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class inherits members to store the account number and the balance from the base class. A customer with a checking account typically receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. Add member variables to store this additional information. In addition to the operations inherited from the base class, this...