Oop Assignment

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Write a java program that simulates a bank system that have a class called BankAcc that have:

- name
- id
- Balance(private)
- Write a default constructor and a parameterized constructor that takes name and id
- Set and get functions for the balance variable
- Two methods called :
• Deposit(double n): that takes a value and increase the balance by this value
• Withdraw(double n): that takes a value, check balance and decrease balance with
this value if he have enough balance or print error message else.
• BTransfere(BankAcc b, double n): that transfer a value of n from the balance of
current account to the balance of account B if the balance is enough

Create a drive class and create three objects of BankAcc class, make a deposit of value 10000.0 for
each account. Withdraw from first object 5000.0 then try to transfer a value of 8000.0 from first
object to the 2nd object then try to transfer a value of 4000 from the second object to the third
object. Print the balance for the three objects.

You might also like