JAVA:JAVA:JAVA:JAVA - Design an abstract class named BankAccount. It has the fol
ID: 3833622 • Letter: J
Question
JAVA:JAVA:JAVA:JAVA
- Design an abstract class named BankAccount. It has the following data fields: balance, annual interest rate, monthly service charge.
- The class has the following methods:
-Constructor
-A method named deposit: to deposit some money to the account
-A method named withdraw: to withdraw some money from the account
-An abstract method named monthlyProcess: this method returns double value.
- Design a child class named SavingsAccount to extend the BankAccount class. The SavingsAccount class has three data fields: Number of deposits, and number of withdraws, and a Boolean type data fields active
- The class has the following methods:
-Constructor:
-Override the deposit method: if the balance after deposit is less than $25, set the account “inactive”, otherwise, set the account “active”
-Override the withdraw method: if the account is inactive, do not allow withdraw. If the balance after withdraw is less than $25, set the account inactive
-Override the abstract method defined in the parent class: $1 extra service fee for each transaction after 4 deposit or withdraw. Base service fee is $10 per month.
BE SURE TO GIVE THE FOLLOWING OUTPUT/DEMO
Explanation / Answer
}
___________________
Test.java
public class Test {
public static void main(String[] args) {
SavingsAccount saver1=new SavingsAccount(2000.00);
SavingsAccount saver2=new SavingsAccount(3000.00);
SavingsAccount.annualInterestRate=4;
System.out.println("Saver 1#");
System.out.println("Month Balance");
for(int i=1;i<12;i++)
{
saver1.calculateMonthlyInterest();
System.out.printf("%d %.2f ",i,saver1.getSavingsBalance());
}
System.out.println("Saver 2#");
System.out.println("Month Balance");
for(int i=1;i<12;i++)
{
saver2.calculateMonthlyInterest();
System.out.printf("%d %.2f ",i,saver2.getSavingsBalance());
}
System.out.println("After changing Interest rate to 5%");
SavingsAccount.modifyInterestRate(5);
System.out.println("Saver 1#");
saver1.calculateMonthlyInterest();
System.out.printf("New Balance of save 1 :%.2f ",saver1.getSavingsBalance());
System.out.println("Saver 2#");
saver1.calculateMonthlyInterest();
System.out.printf("New Balance of saver 2 :%.2f ",saver1.getSavingsBalance());
}
}
___________________
Output:
Saver 1#
Month Balance
1 2006.67
2 2013.36
3 2020.07
4 2026.80
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.