Write the java code for an abstract class about banking
Write the Java code for an abstract class named Account which has two data members; one for the account number and the other for the account balance (use information hiding). The Account class should include get and set methods for both data members and a constructor that initializes the two data members from the values received in the parameter list. Create (override) the toString() method that returns a string indicating the account number and the account balance. In addition to these methods, the Account class will have one abstract method called calculateInterest. The calculateInterest method will take one argument representing the interest rate and will return an amount representing the interest calculated based on the balance.
In addition to the Account superclass, write the code for two subclasses: CheckingAcct and SavingsAcct. The CheckingAcct interest is calculated only if the account balance is over 700 dollars. The checking account should also be able to tell the user if cosignatories are required or not with the default being not required. The SavingAcct interest is calculated on any balance greater than zero. The SavingsAcct constructor should initialize its only data member called accumulatedInterest to zero. Assume the interest calculation is for the year and the rate is 7%.
Write the code for a class named TestAccounts that will create an array of 3 Account references, instantiates two CheckingAcct objects and one SavingsAcct object, and then assigns the CheckingAcct objects to the first two array elements to the array mentioned above, and the SavingsAcct object to the third. Create a loop that calls the calculateInterest method and then displays the interest for all three accounts using the array references.
12 years ago 5
Purchase the answer to view it
- java.zip
Purchase the answer to view it
- src.zip
- Do Reflective Essay
- project 8
- 5 Physic problem
- accguru
- performance management
- performance management
- research findings in the area of interpersonal attraction indicate that individuals are most likely to be attracted to others who...
- Find out more about how the kidney filter removes waste from the blood.
- At a certain temperature, the solubility of strontium arsenate, Sr3(AsO4)2, is 0.0640 g/L. What is the Ksp of this salt...
- Discrete Math