-
Notifications
You must be signed in to change notification settings - Fork 0
Practice Problem 12
Seanti edited this page Mar 26, 2025
·
1 revision
-
Create a
BankAccountclass with attributes:-
accountNumber(String) -
balance(double)
-
-
Add methods for:
-
deposit(double amount): Adds money to the account. -
withdraw(double amount): Deducts money (check if balance is enough). -
displayBalance(): Displays the balance.
-
-
In
main(), create an object ofBankAccountand test all methods.
Enter account number: 123456
Enter initial balance: 5000
1 - Deposit
2 - Withdraw
3 - Check Balance
4 - Exit
Enter your choice: 1
Enter deposit amount: 2000
Deposit successful!
1 - Deposit
2 - Withdraw
3 - Check Balance
4 - Exit
Enter your choice: 2
Enter withdrawal amount: 3000
Withdrawal successful!
1 - Deposit
2 - Withdraw
3 - Check Balance
4 - Exit
Enter your choice: 3
Current balance: 4000
1 - Deposit
2 - Withdraw
3 - Check Balance
4 - Exit
Enter your choice: 4
Exiting program.