Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q3(30p). Write a class called BankAccount. The class must have 3 attributes: accountNo(int), holderName(String) and balance(double). a) Class constructor will have to set these 3

image text in transcribed

Q3(30p). Write a class called BankAccount. The class must have 3 attributes: accountNo(int), holderName(String) and balance(double). a) Class constructor will have to set these 3 attributes. b) Create a balanceChange(double amount) method to reduce balance value by given amount. c) In the Main method: 1. Create 4 objects (a1, a2, a3, a4) from this class and add them all to an ArrayList called myAccounts. List will only accept BankAccount type. 2. Sort objects by holderName in the list. (Hint: implement Comparable interface) 3. Reduce the balances by 500 for all the accounts and print sorted objects in the list. BankAccount adnda bir class yazn. Snfn 3 zellii olmaldr: accountNo(int), holderName(String) ve balance(double). a) Constructor un bu 3 zellii ayarlamas (set etmesi) gerekecektir. b) balabce deerini verilen miktar kadar azaltmak iin bir balanceChange(double amount) metodu oluturun. c) main metodda: 1. Bu classtan 4 nesne (a1, a2, a3, a4) oluturun ve hepsini myAccounts adl bir ArrayList'e ekleyin. Liste yalnzca BankAccount trn kabul edecektir. 2. Listedeki nesneleri holderName'e gre sralayn. (pucu: Comparable interface'ni uygulayn) 3. Tm hesaplar iin balance deeri 500 azaltn ve listedeki sral nesneleri yazdrn

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

6. Do Exercise 4 for the STRO instruction.

Answered: 1 week ago