Description
In this program, there are two classes Account.java and TestAccount.java.
Account.java : Write a class named Account that holds the balance of a user and unique account id number.
You should implement following ones;
A constructor: it should set account id and balance.
The get methods for balance and the account id.
deposit method to add more money to current balance.
withdraw method to subtract money from current balance. It returns true if the withdraw operation successful (account has enough money) and false if it fails.
toString method is already implemented. You do not need to change it.
All variables should be private.
TestAccount.java: This class will be used for test purposes. You must not change anything from this class. It asks number of accounts to the user and creates with a unique id and balance then displays a menu that show action list.
You should control your program with the example run given below.
Example Run:
Enter number of Accounts: 3
Type a unique account id: 1
Type a balance for account 1: 12
Type a unique account id: 1
Type a unique account id: 2
Type a balance for account 2: 23
Type a unique account id: 3
Type a balance for account 3: 45
Menu:
1 – Display all accounts.
2 – Deposit money.
3 – Withdraw money.
0– Exit.
Enter an option: 1
Account 1 has 12.0 TL in the bank.
Account 2 has 23.0 TL in the bank.
Account 3 has 45.0 TL in the bank.
Menu:
1 – Display all accounts.
2 – Deposit money.
3 – Withdraw money.
0 – Exit.
Enter an option: 2
Enter account id to deposit: 5
Account id 5 does not exist.
Menu:
1 – Display all accounts.
2 – Deposit money.
3 – Withdraw money.
0 – Exit.
Enter an option: 2
Enter account id to deposit: 1
Enter the amount to deposit: 70
Deposit successfully completed.
Menu:
1 – Display all accounts.
2 – Deposit money.
3 – Withdraw money.
0 – Exit.
Enter an option: 3
Enter account id to withdraw: 2
Enter the amount to withdraw: 45
Account 2 does not have enough balance. Withdraw canceled.
Menu:
1 – Display all accounts.
2 – Deposit money.
3 – Withdraw money.
0 – Exit.
Enter an option: 3
Enter account id to withdraw: 2
Enter the amount to withdraw: 10
Withdraw successfully completed.
Menu:
1 – Display all accounts.
2 – Deposit money.
3 – Withdraw money.
0 – Exit.
Enter an option: 1
Account 1 has 82.0 TL in the bank.
Account 2 has 13.0 TL in the bank.
Account 3 has 45.0 TL in the bank.




Reviews
There are no reviews yet.